poj 2352
来源:互联网 发布:ones刻录软件 编辑:程序博客网 时间:2024/06/08 15:58
因为输入的坐标按 y 值递增 当 y 相同时 按 x 递增 所以 树状数组可以直接解决~~
/************************************************************************* > Author: xlc2845 > Mail: xlc2845@gmail.com > Created Time: 2013年11月07日 星期四 21时06分32秒 ************************************************************************/#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <queue>#define LL long long#define maxn 32000+10using namespace std;int a[maxn], level[15010];int lowbit(int x){ return x&-x;}int sum(int x){ int ret = 0; while(x > 0) ret += a[x], x -= lowbit(x); return ret;}void add(int x){ while(x < maxn) a[x]++, x += lowbit(x);}int main(){ int n; while(scanf("%d", &n) == 1 && n) { memset(a, 0, sizeof(a)); memset(level, 0, sizeof(level)); for(int i = 0; i < n; i++) { int x, y; scanf("%d%d", &x, &y); level[sum(x+1)]++; add(x+1); } for(int i = 0; i < n; i++) printf("%d\n",level[i]); } return 0;}
- poj 2352
- poj 2352
- poj 2352
- poj 2352
- poj 2352
- poj 2352
- poj 2352
- poj 2352
- poj 2352
- poj-2352
- POJ 2352
- poj 2352
- poj-2352
- poj 2352
- poj 2352
- POJ 2352
- poj 2352
- POJ 2352 STARS
- mat容器
- 2013年最后2个月的学习目标(计划)
- C++中的多态总结二
- 帧间差分法_OpenCV_详解
- Linux驱动学习笔记(二)--kset内核对象集合
- poj 2352
- (DFS11.2.1)UVA 291 The House Of Santa Claus(使用DFS来解决一笔画问题)
- bnu 33967 Boxes in a Line 链表模拟
- hdu3790最短路径
- WebService说明书的书写
- 2013年最后2个月的学习目标(成果)(上次更新2013年11月18日)
- OCP-1Z0-053-V12.02-271题
- Hello, Android Studio!
- android强制隐藏键盘(当edittext获得焦点时不弹出键盘)