Stars
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
(1<=N<=15000). The following N lines describe coordinates of stars
(two integers X and Y per line separated by a space,
0<=X,Y<=32000). There can be only one star at one point of the
plane. Stars are listed in ascending order of Y coordinate. Stars with
equal Y coordinates are listed in ascending order of X coordinate.
Output
line contains amount of stars of the level 0, the second does amount of
stars of the level 1 and so on, the last line contains amount of stars
of the level N-1.
Sample Input
5
1 1
5 1
7 1
3 3
5 5
Sample Output
1
2
1
1
0
Hint
#include <iostream>
#include <cstdio>
using namespace std;
int n,x,y;
int tree[],level[];
int lowbit(int t)
{
return t&-t;
}
void update(int x,int y)
{
for(int i = x;i <= ;i += lowbit(i))
{
tree[i] += y;
}
}
int gettree(int x)
{
int ans = ;
for(int i = x;i > ;i -= lowbit(i))
{
ans += tree[i];
}
return ans;
}
int main()
{
scanf("%d",&n);
for(int i = ;i < n;i ++)
{
scanf("%d%d",&x,&y);
x ++;
level[gettree(x)] ++;
update(x,);
}
for(int i = ;i < n;i ++)
{
printf("%d\n",level[i]);
}
}
Stars的更多相关文章
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
- POJ 2352 Stars(树状数组)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 30496 Accepted: 13316 Descripti ...
- 【POJ-2482】Stars in your window 线段树 + 扫描线
Stars in Your Window Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11706 Accepted: ...
- Java基础之在窗口中绘图——填充星型(StarApplet 2 filled stars)
Applet程序. import javax.swing.*; import java.awt.*; import java.awt.geom.GeneralPath; @SuppressWarnin ...
- XidianOJ 1177 Counting Stars
题目描述 "But baby, I've been, I've been praying hard, Said, no more counting dollars We'll ...
- POJ-2352 Stars 树状数组
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 39186 Accepted: 17027 Description A ...
- hdu 1541/poj 2352:Stars(树状数组,经典题)
Stars Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- POJ 2482 Stars in Your Window 线段树扫描线
Stars in Your Window Description Fleeting time does not blur my memory of you. Can it really be 4 ...
- 2015ACM/ICPC亚洲区长春站 G hdu 5533 Dancing Stars on Me
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- Stars(树状数组或线段树)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37323 Accepted: 16278 Description A ...
随机推荐
- overflow应用场景
overflow属性可以设置的值有5种: (1)visible 默认值,内容不会裁剪,呈现在元素框之外: (2)hidden 内容会被裁剪,并且子元素内容是不可见的: (3)scroll 内容会被裁 ...
- Nginx rewrite配置
rewrite应用 Rewrite模块设置及Wordpress和Discuz的示例.Nginx的Rewrite规则比Apache的简单灵活多了,从下面介绍可见一斑. rewrite配置 Nginx可以 ...
- 20145201《Java程序设计》第十周学习总结
教材学习内容总结 网络编程 网络编程就是在两个或两个以上的设备(例如计算机)之间传输数据. 程序员所作的事情就是把数据发送到指定的位置,或者接收到指定的数据,这个就是狭义的网络编程范畴. 在发送和接收 ...
- JavaWeb HTML
1. HTML介绍 1.1. 什么是HTML HTML的全称为Hyper Text Markup Language,译为超文本标记语言. 超文本,就是指页面内可以包含图片.链接,甚至音乐.程序等非文字 ...
- 什么是webhook
什么是webhook 翻译,原文地址:https://sendgrid.com/blog/webhook-vs-api-whats-difference/ 一.概述 Webhook是一个API概念,并 ...
- adjacent cache line prefetch
adjacent cache line prefetch 预读取邻近的缓存数据. 计算机在读取数据时,会智能的认为要读取的数据旁边或邻近的数据也是需要的, 那么其在处理的时候就会将这些邻近的数据预先读 ...
- Idea中解决Git中pull代码内容冲突
Git开发中,由于项目开发人员不只一个,所以在代码开发中,多个开发人员可能会对同一文件同一地方的代码进行修改,这样在先后提交到master上时,就会产生冲突,以下是演示冲突产生和解决冲突的示例: 1. ...
- Filter FASTA files
Use a regular expression for filtering sequences by id from a FASTA file, e.g. just certain chromoso ...
- 谷歌SEO老域名注册完全攻略
老域名有优势,不管在百度和谷歌都是一样的. 我们查看搜索结果就能发现,谷歌里面很多排前十的网站都是N年前的,一零年以后的算是比较新的,很多产品网站域名是零几年,甚至很多排名更好的域名是九几年的. 谷歌 ...
- Github删除账号方法
1.登录后点击头像,选择Settings 2.选择Account,然后再选择Delete your account 3.第一个输入框输入邮箱或者用户名,第二个输入框输入delete my accoun ...