树状数组 poj2352 Stars
2019-05-20
22:52:07
加油,坚持,加油,坚持 !!!
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; const int MAXN = ; int c[MAXN],level[MAXN],n; int lowbit(int x){return x & (-x);} // 求前n项的和
int sum(int n){
int sum = ;
while(n > ){
sum += c[n];
n -= lowbit(n);
}
return sum;
}
// 增加某个元素的大小
void add(int x){
while(x <= MAXN){
++c[x];
x += lowbit(x);
}
} int main(){
int n,x,y;
while(~scanf("%d",&n)){
memset(level, , sizeof(level));
memset(c, , sizeof(c));
for(int i=; i<n; ++i) {
scanf("%d%d",&x,&y);
++x;
level[sum(x)]++;
add(x);
}
for(int i=; i<n; ++i)
printf("%d\n",level[i]);
}
return ;
}
树状数组 poj2352 Stars的更多相关文章
- 树状数组POJ2352星星
http://poj.org/problem?id=2352 这道题的题意对于住学者应该比较难理解,但是如果弄明白他的意思的话,你就会发现这就是赤裸裸的树状数组,哎,欺负我不懂是吧,当时读题读啦好久, ...
- 树状数组 - 2352 Stars
题目地址: http://poj.org/problem?id=2352 分析: - 题意分析: 有n个星星, 它的左下方(x和y不超过它)的星星的数目就是它的level, 分别计算level 为 ...
- 【POJ2352】【树状数组】Stars
Description Astronomers often examine star maps where stars are represented by points on a plane and ...
- POJ-2352 Stars 树状数组
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 39186 Accepted: 17027 Description A ...
- poj2352 Stars【树状数组】
Astronomers often examine star maps where stars are represented by points on a plane and each star h ...
- 【二维偏序】【树状数组】【权值分块】【分块】poj2352 Stars
经典问题:二维偏序.给定平面中的n个点,求每个点左下方的点的个数. 因为 所有点已经以y为第一关键字,x为第二关键字排好序,所以我们按读入顺序处理,仅仅需要计算x坐标小于<=某个点的点有多少个就 ...
- POJ 2352 Stars(树状数组)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 30496 Accepted: 13316 Descripti ...
- hdu 1541/poj 2352:Stars(树状数组,经典题)
Stars Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- Stars(树状数组或线段树)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37323 Accepted: 16278 Description A ...
随机推荐
- 【PLSQL】游标
Oracle中的SQL在执行时需要分配一块内存区域,这块内存区域叫做上下文区. 上下文区中记录了SQL语句的处理信息,这些信息包括:查询返回的数据行.查询所处理的数据的行号.指向共享池中的已分析的SQ ...
- REST、RESTful、SOA
1.http://www.imooc.com/article/17650 2.SOA面向服务架构
- redis-linux
redis3.0.4 server版本 jedis-2.7.2.jar spring-data-redis-1.6.0.RELEASE.jar commons-pool2-2.3.jar spring ...
- [Intermediate Algorithm] - Binary Agents
题目 传入二进制字符串,翻译成英语句子并返回. 二进制字符串是以空格分隔的. 提示 String.charCodeAt() String.fromCharCode() 测试用例 binaryAgent ...
- 输出字符串格式化/ Linq对数组操作 /一个按钮样式
textBox1.Text = dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss"); , , , , , , , , , , ...
- rabbitmq和kafka的区别
1.吞吐量kafka吞吐量更高: 1)Zero Copy机制,内核copy数据直接copy到网络设备,不必经过内核到用户再到内核的copy,减小了copy次数和上下文切换次数,大大提高了效率. 2)磁 ...
- jupyter notebook主目录修改
转自http://blog.csdn.net/c437yuyang/article/details/54836303 1.打开 cmd 输入命令 jupyter notebook --generate ...
- 编写输出Hellow word!
打开java运行环境(eclipse),然后输入以下语句,点击编译运行后即可输出“Hello World,”. public class HelloWorld { public static void ...
- poj 2763(LCA + dfs序 +树状数组)
算是模板题了 可以用dfs序维护点到根的距离 注意些LCA的时候遇到MAXM,要-1 #include<cstdio> #include<algorithm> #include ...
- Luogu P1198 BZOJ 1012 最大数 (线段树)
手动博客搬家: 本文发表于20170821 14:32:05, 原地址https://blog.csdn.net/suncongbo/article/details/77449455 URL: (Lu ...