POJ2352 Stars 树状数组
来源:互联网 发布:借壳上市案例分析 知乎 编辑:程序博客网 时间:2024/05/21 09:27
- 他已经按照顺序给你得了,不需要我们另外排序,直接忽略y即可,只看x。
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- #include <string>
- #include <stack>
- #include <queue>
- #include <map>
- #include <set>
- #include <vector>
- #include <math.h>
- #include <bitset>
- #include <list>
- #include <algorithm>
- #include <climits>
- using namespace std;
- #define lson 2*i
- #define rson 2*i+1
- #define LS l,mid,lson
- #define RS mid+1,r,rson
- #define UP(i,x,y) for(i=x;i<=y;i++)
- #define DOWN(i,x,y) for(i=x;i>=y;i--)
- #define MEM(a,x) memset(a,x,sizeof(a))
- #define W(a) while(a)
- #define gcd(a,b) __gcd(a,b)
- #define LL long long
- #define N 32005
- #define INF 0x3f3f3f3f
- #define EXP 1e-8
- #define lowbit(x) (x&-x)
- const int mod = 1e9+7;
- int a[N];
- int n,c[N],ans[N],x,y;
- int sum(int x)
- {
- int ret=0;
- while(x>0)
- {
- ret+=c[x];
- x-=lowbit(x);
- }
- return ret;
- }
- void add(int x,int d)
- {
- while(x<=N)
- {
- c[x]+=d;
- x+=lowbit(x);
- }
- }
- int main()
- {
- int i,j,k;
- while(~scanf("%d",&n))
- {
- MEM(c,0);
- MEM(ans,0);
- for(i = 1; i<=n; i++)
- {
- scanf("%d%d",&x,&y);
- x++;
- ans[sum(x)]++;
- add(x,1);
- }
- for(i = 0; i<n; i++)
- printf("%d\n",ans[i]);
- }
- return 0;
- }
阅读全文
0 0
- 【树状数组】 poj2352 Stars
- POJ2352 stars(树状数组)
- poj2352 - Stars(树状数组)
- poj2352 Stars 树状数组
- POJ2352:Stars(树状数组)
- POJ2352 Stars(树状数组)
- POJ2352 Stars 树状数组
- POJ2352 Stars[树状数组]
- 【poj2352】【树状数组】Stars
- poj2352 Stars (树状数组)
- POJ2352 Stars 树状数组
- POJ2352 Stars 树状数组
- poj2352 Stars(树状数组)
- 【树状数组】poj2352 stars
- POJ2352 Stars 树状数组
- poj2352 Stars (树状数组)
- POJ2352 Stars(树状数组)
- 【树状数组】尝试 POJ2352-Stars
- 自定义 ViewGroup(一)
- [python]打印对齐
- SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- 在什么样的场景下,需要利用到Java的反射特性编程?
- Linus Benedict Torvalds-a giant to push the world forward
- POJ2352 Stars 树状数组
- 解决 git 无法 push 的问题
- 如何理解数据结构当中的树?
- 简单的理解HTTP协议
- Linux系统之用户加密
- lua table排序
- 图像特效之挤压特效
- 权力下放相关
- 51nod 1770 数数字