POJ 2352 数星星
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 53816 | Accepted: 23159 |
Description
For example, look at the map shown on the figure above. Level of the star number 5 is equal to 3 (it's formed by three stars with a numbers 1, 2 and 4). And the levels of the stars numbered by 2 and 4 are 1. At this map there are only one star of the level 0, two stars of the level 1, one star of the level 2, and one star of the level 3. You are to write a program that will count the amounts of the stars of each level on a given map.
Input
Output
Sample Input
5
1 1
5 1
7 1
3 3
5 5
Sample Output
1
2
1
1
0
Hint
Source
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,i,j,k,u,v,ans[] ={},tree[] = {};
struct node
{
int x;
int y;
}a[];
int lowbit(int x)
{
return x & (-x);
}
void add(int l,int x)
{
while(l <= )
{
tree[l] += x;
l += lowbit(l);
}
}
int sum(int p)
{
int res = ;
while(p > )
{
res += tree[p];
p -= lowbit(p);
}
return res;
}
int main()
{
scanf("%d",&n);
for(i = ;i <= n;i++)
{
scanf("%d %d",&a[i].x,&a[i].y);
}
for(i = ;i <= n;i++)
{
u = a[i].x + ;
v = sum(u);
ans[v] += ;
add(u,);
}
for(i = ;i < n;i++)
{
printf("%d",ans[i]);
if(i != n)
printf("\n");
}
return ;
}
POJ 2352 数星星的更多相关文章
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
- codev 2147 数星星
2147 数星星 http://codevs.cn/problem/2147/ 题目描述 Description 小明是一名天文爱好者,他喜欢晚上看星星.这天,他从淘宝上买下来了一个高级望远镜.他十分 ...
- 题解西电OJ (Problem 1008 - 数星星)
题目内容: Description “不要问我太阳有多高 我会告诉你我有多真 不要问我星星有几颗 我会告诉你很多很多” 一天Qinz和wudired在天上数星星,由于星星可以排列成一条直线,他们比赛看 ...
- 一本通1536数星星 Stars
1536:[例 2]数星星 Stars 时间限制: 256 ms 内存限制: 65536 KB [题目描述] 原题来自:Ural 1028 天空中有一些星星,这些星星都在不同的位置,每 ...
- codevs 2147 数星星
2147 数星星 http://codevs.cn/problem/2147/ 题目描述 Description 小明是一名天文爱好者,他喜欢晚上看星星.这天,他从淘宝上买下来了一个高级望远镜.他十分 ...
- codevs——2147 数星星
2147 数星星 时间限制: 3 s 空间限制: 64000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Description 小明是一名天文爱好者,他喜欢晚上看星星 ...
- codevs2147数星星(哈希)
2147 数星星 时间限制: 3 s 空间限制: 64000 KB 题目等级 : 钻石 Diamond 题目描述 Description 小明是一名天文爱好者,他喜欢晚上看星星.这天,他从淘 ...
- 大红数星星 图论 XD网络赛
问题 A: 大红数星星 时间限制: 3 Sec 内存限制: 128 MB提交: 1066 解决: 67[提交][状态][讨论版] 题目描述 “三角形十分的美丽,相信大家小学就学过三角形具有稳定性, ...
- POJ 2352 Stars(线段树)
题目地址:id=2352">POJ 2352 今天的周赛被虐了. . TAT..线段树太渣了..得好好补补了(尽管是从昨天才開始学的..不能算补...) 这题还是非常easy的..维护 ...
随机推荐
- oracle 与其他数据库如mysql的区别
想明白一个问题:(1)oracle是以数据库为中心,一个数据库就是一个域(可以看作是一个文件夹的概念),一个数据库可以有多个用户,创建用户是在登陆数据库之后进行的,但是有表空间的概念(2)而mysql ...
- openlayer ol.js和ol-debug.js的使用 调试技巧
二者实现的功能是一样的,有以下区别 : ol.js一般打包项目的时候使用, ol-debug.js编写代码调试的时候使用. 下边是用ol-debug.js编写代码调试的显示: 编写代码调试的技巧,所有 ...
- JaveWeb 公司项目(2)----- 类模态窗口显示DIV并将DIV放置在屏幕正中间
上一篇博客写的是通过隐藏显示进行div的替换,接下来需要在原有的div前添加一个div,进行表单的提交,需要将div放置在正中间,然后类似C#中的模态窗口,在进行完新弹出的div操作之后,才可以进行下 ...
- Windows android appium python3 环境搭建
安装nodejs https://www.cnblogs.com/sea-stream/p/10520624.html java 环境变量配置: https://www.cnblogs.com/sea ...
- CentOS6.5下安装配置MySQL数据库
一.MySQL简介 说到数据库,我们大多想到的是关系型数据库,比如MySQL.Oracle.SQLServer等等,这些数据库软件在Windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...
- (转)c# String与StringBuilder
阅读目录 1.什么时候用String?什么时候用StringBuilder? 2.String与StringBuilder的区别 总结 1.什么时候用String?什么时候用StringBuild ...
- Windows 7 Update Settings Disabled (Important Updates Grayed Out)
This worked for me: 1) Hold WindowsKey + R (is hold Start & press R on your keyboard) 2) Typ ...
- how-to-view-source-of-chrome-extension
https://gist.github.com/paulirish/78d6c1406c901be02c2d Option 1: Command-line download extension as ...
- Effective java 系列之避免过度同步和不要使用原生态类型,优先考虑泛型
避免过度同步(67):在一个被同步的方法或代码块中,不要调用哪些被设计成被覆盖的方法或者是由客户端以函数对象的形式提供的方法(21). 有点拗口,书上提供的创建者与观察者模式,add方法太多,看得眼花 ...
- Lab 3-1
Analyze the malware found in the file Lab03-01.exe using basic dynamic analysis tools. Questions and ...