树状数组 poj2352 Stars】的更多相关文章

2019-05-20 22:52:07 加油,坚持,加油,坚持 !!! #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; int c[MAXN],level[MAXN],n; int lowbit(int x){return x & (-x);} // 求前n项的和 int sum(int n){ ; ){ sum += c[n]; n -= lowbit(n…
http://poj.org/problem?id=2352 这道题的题意对于住学者应该比较难理解,但是如果弄明白他的意思的话,你就会发现这就是赤裸裸的树状数组,哎,欺负我不懂是吧,当时读题读啦好久,好啦,下面说一下他的意思吧.. 由于题目已经说明y的坐标是递增顺序,所以直接考虑x的坐标就可以啦.每次当有x输入时,都求出sum(x+1)的值(注意呦,在树状数组中,可是从1开始的,而题目中的输入是包含0的),并把result[sum(x+1)]++:再更新一下,就好啦啦啦啦. 还是要注意一点,用c…
题目地址: http://poj.org/problem?id=2352 分析: - 题意分析:  有n个星星, 它的左下方(x和y不超过它)的星星的数目就是它的level, 分别计算level 为 0 到 n-1 的星星的数目. 输入是先按照 y 从小到大排序, 如果y相同,就按照x递增排序, 不会有2个以上星星占同一个坐标. - 数据结构 - 用原始数据数组 a 表示同一个x坐标的星星数目. (a[i]为x坐标为 i-1的星星数目).  注意输入数据时排序的. - 树状数组s维护a的信息.…
Description 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 the right of the given star. As…
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 39186 Accepted: 17027 Description 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 b…
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 the right of the given star. Astronomers wa…
经典问题:二维偏序.给定平面中的n个点,求每个点左下方的点的个数. 因为 所有点已经以y为第一关键字,x为第二关键字排好序,所以我们按读入顺序处理,仅仅需要计算x坐标小于<=某个点的点有多少个就行. 这就是所说的:n维偏序,一维排序,二维树状数组,三维 分治 Or 树状数组套平衡树…… <法一>树状数组. #include<cstdio> #include<algorithm> #include<iostream> using namespace st…
Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30496   Accepted: 13316 Description 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 st…
Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4052    Accepted Submission(s): 1592 Problem Description Astronomers often examine star maps where stars are represented by points on a plan…
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37323 Accepted: 16278 Description 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 b…