树状数组 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 ...
随机推荐
- 【SQL】数值型函数
1. CEIL 语法:CEIL(n) 作用:取大于等于数值n的最小整数 SQL> select ceil(9.1),ceil(9.9),ceil(9) from dual; CEIL(9.1) ...
- Glitch-free clock switch
With multi-frequency clocks being used in today’s devices, it's necessary to switch the source of a ...
- css属性代码大全总结(一)
一 CSS文字属性: color : #999999; /*文字颜色*/ font-family : 宋体,sans-serif; /*文字字体*/ font-size : 9pt; /*文字大小*/ ...
- 工作中总结的经验之git篇
不要以为你会git,你要知道,git不是只有commit和push 由于系统分析与设计的期末Project需要团队合作开发,因此在这里想谈谈GitHub团队项目合作开发的流程: 项目创建 项目负责人在 ...
- (转)Arcgis for JS实现台风运动路径与影像范围的显示
http://blog.csdn.net/gisshixisheng/article/details/42025435 首先,看看具体的效果: 初始化状态 绘制中 绘制完成 首先,组织数据.我组织的数 ...
- Python基础知识-Day4
一.函数关键字关键字是Python内置的,具有特殊意义的标识符,自定义标识符命名时不可与之重复.可以通过以下代码查看Python内置的关键字内容. import keyword print(keywo ...
- Labview学习笔记(一)
一.概述 Labview是一种工业标准图形化编程工具,主要用于开发测试.测量与控制系统,拥有一个可以完成任何编程任务的庞大函数库,包括数据采集.GPIB.串口控制.数据分析.数据显示及数据存储等. L ...
- [kernel学习]----如何debug kernel
#ll /sys/kernel/debug/tracing/events/kmem total 0 -rw-r--r-- 1 root root 0 Feb 3 20:17 enable -rw-r- ...
- C#第二节课
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- lunix下的redis数据库操作——zset有序集合
创建:(有序集合存在一个权重的概念) zadd zset 1 a 2 b 3 c 4 d 5 e 6 f 7 g # 输出: # 1) "a" # 2) "b" ...