非静态成员函数可以通过fac.inrange调用静态成员函数属于类一级的,所以可以用域操作符访问方法
二维偏序问题,用树状数组解决。本题看似二维,但给出的数据就是已经按照y从小到大排好序的,也就是说,当前读到一个点的时候,当前点的y坐标肯定比已经读入的大,或者等于。就算是等于的话,也是x坐标比我当前点的x坐标小。这样一来,我们如果按照读入顺序来处理,则保证了后面点的y坐标一定大于前面的点,所以我们每次只需统计x坐标比我们当前点小的个数就行了。注意:给的点的坐标是从0开始的,树状数组下标从1开始(0
转载 2021-03-27 09:05:18
132阅读
2评论
树状数组,注意树状数组范围View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxm 32005int n, ans[maxm];int ar[maxm];int lowb(int t){ return t & (-t);}void add(int i, int v){ for (; i < maxm; ar[i] += v, i += lowb(i)) ;}int
转载 2011-05-24 18:59:00
23阅读
2评论
树状数组:注意,这种大数据的题,千万别作死用cin我已经光荣的被T了一次了= =#include#include#includeusing namespace std;const int maxn=32005;int c[maxn],level[maxn],n;int lowbit(int x){ ...
IT
原创 2021-07-16 14:59:09
81阅读
2011-12-20 05:12:48地址:http://acm.hdu.edu.cn/showproblem.php?pid=2352题意:罗马数字转阿拉伯数字。mark:居然wa了一次。把%d写成了%s,太2了。看似麻烦,其实简单。降序为正,升序为负,遍历即可。代码:# include <stdio.h>char str[110] ;int num[110] ;int n ;int calc(){ int i, j, ans = 0 ; for (i = 0 ; i < n ; i++) { ans += num[i] ; for (j = i...
转载 2012-01-06 22:43:00
27阅读
【题目链接】 http://poj.org/problem?id=2352 【算法】 树状数组 注意x坐标为0的情况 【代码】
转载 2018-07-13 16:23:00
116阅读
2评论
POJ_2352     由于我们在读入数据的时候已知了前面星星的个数,实际上再减去当前星星右边的星星的数量即可,因此我们可以用一个线段树存储横坐标区间里的星星个数,每读入一个星星就修改并查询一次,并记录level即可。 #include<stdio.h>#include<string.h>#define MAXD 32010#define MAXN 15010int M
转载 2011-11-01 18:58:00
67阅读
2评论
StarsTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 27342Accepted: 11961Description Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to
转载 2013-09-05 17:49:00
59阅读
2评论
POJ 2352 Stars Description Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinate
树状数组
原创 2023-02-17 08:46:59
40阅读
题意理解了半天,基础的树状数组
原创 2023-03-03 12:40:45
60阅读
POJ - 2352  StarsAstronomers often examine star maps where stars a
原创 2023-03-02 09:32:02
69阅读
题目传送门 视频讲解I:https://www.bilibili.com/video/av625268851 视频讲解II:https://www.bilibili.com/video/BV1Tk4y1m7VM?p=31 一、题目大意 给出$n$个点坐标, 按照$y$升序的顺序, 若$y$相同, 则
原创 2022-05-13 17:02:04
56阅读
二维偏序:第一维排序,第二维树状数组或线段树。
转载 2016-05-20 17:55:00
79阅读
2评论
纪念树状数组初步(……); 这题已经给了y升序,y相同时x升序,(yeah) 所以容易想到O(n^2)的模拟算法; 其实分析一下就是对于当前xi,统计之前有多少个小于等于xi(因为已经保证了没有相同坐标的点) 初学者(比如我),一开始感觉和树状数组没毛关系,但是…… 仔细想想发现,树状数组是修改和区间求值的,我们能不能将问题转化呢? 可以!这里用到类似计数排序的思想,a数组表示对x可能出现的范围内
转载 2013-12-08 22:44:00
59阅读
2评论
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 42707 Accepted: 18587 Description Astronomers often examine star maps where stars are
转载 2016-09-08 21:39:00
57阅读
http://poj.org/problem?id=2352 题意: 给出每个星星的x、y坐标,计算每颗星星左方和正下方的星星个数。 思路:由于星星是根据y坐标递增的基础上再根据x坐标递增的顺序给出,所以我们只需要考虑横坐标上的星星情况,至于正下方的星星个数,我们只需要记录一下最后加上即可。
转载 2017-05-07 19:24:00
54阅读
2评论
// 668K 422MS G++#include #include const int MAX = 32767;const int LEVEL_MAX = 15100;int tree[MAX<<1];int levelNum[LEVEL_MAcurId, int x, int begin, int en
原创 2023-05-23 16:04:01
41阅读
嘟嘟嘟 二维偏序。 按y排序,在x方向上用树状数组维护前缀和。 因为输入保证排好序了,所以y没什么用。 x可以等于0,所以最好在输入的时候加1,否则会TLE…… 1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 #include<
原创 2021-05-29 19:09:35
87阅读
http://poj.org/problem?id=2352二维逆序数 按一个数排序 转化为1维的 之前用树状数组写过 这次用线段树敲了下 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 32010 8 struct node 9 {10 int x, y;11 }st[N];12 int s[N>1;27 build(l,m,w>1;42 if(p=r)51 {52 return s[w];53 }54 ...
转载 2013-07-14 20:32:00
57阅读
2评论
  • 1
  • 2
  • 3
  • 4
  • 5