POJ——T2352 Stars
http://poj.org/problem?id=2352
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 46592 | Accepted: 20096 |
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 <algorithm>
#include <cstdio> #define lowbit(x) (x&(-x)) using namespace std; const int N();
const int N_();
int n;
struct TypeNodeStar
{
int x,y;
}star[N]; bool cmp(TypeNodeStar a,TypeNodeStar b)
{
if(a.x!=b.x) return a.x<b.x;
return a.y<b.y;
} int c[N_];
int ans[N],t[N_]; int query(int x)
{
int ans=;
for(;x;x-=lowbit(x)) ans+=t[x];
return ans;
} void insert(int x)
{
for(;x<=N_;x+=lowbit(x)) t[x]++;
} int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d",&star[i].x,&star[i].y);
star[i].x++; star[i].y++;
}
sort(star+,star+n+,cmp);
for(int i=;i<=n;i++)
{
int tmp=query(star[i].y);
insert(star[i].y);
ans[tmp]++;
}
for(int i=;i<n;i++) printf("%d\n",ans[i]);
return ;
}
POJ——T2352 Stars的更多相关文章
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
- poj 2482 Stars in Your Window(扫描线)
id=2482" target="_blank" style="">题目链接:poj 2482 Stars in Your Window 题目大 ...
- POJ 2482 Stars in Your Window(线段树)
POJ 2482 Stars in Your Window 题目链接 题意:给定一些星星,每一个星星都有一个亮度.如今要用w * h的矩形去框星星,问最大能框的亮度是多少 思路:转化为扫描线的问题,每 ...
- [poj P2482] Stars in Your Window
[poj P2482] Stars in Your Window Time Limit: 1000MS Memory Limit: 65536K Description Fleeting time ...
- POJ 2352 Stars(树状数组)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 30496 Accepted: 13316 Descripti ...
- poj 2482 Stars in Your Window + 51Nod1208(扫描线+离散化+线段树)
Stars in Your Window Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13196 Accepted: ...
- poj 2482 Stars in Your Window (线段树:区间更新)
题目链接:http://poj.org/problem?id=2482 读完题干不免有些心酸(
- 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 ...
随机推荐
- UVa11183 - Teen Girl Squad(最小树形图-裸)
Problem I Teen Girl Squad Input: Standard Input Output: Standard Output -- 3 spring rolls please. - ...
- [Angular] Service Worker Version Management
If our PWA application has a new version including some fixes and new features. By default, when you ...
- 1003. 我要通过!(20) (ZJUPAT 模拟)
题目链接:http://pat.zju.edu.cn/contests/pat-b-practise/1003 "答案正确"是自己主动判题系统给出的最令人欢喜的回复.本题属于PAT ...
- mysql基础综述(四)
1.数据库的简单介绍 1.1 数据库,就是一个文件系统,使用标准sql对数据库进行操作 1.2 常见的数据库 oracle 是oracle公司的数据库,是一个收费的大型的数据库 DB2,是IBM公司 ...
- Shiro 学习应用(续)
在前面的文章中为大家介绍了 Shrio 的基础概念.可能比較笼统.没有深入到开发过程的一些问题.如今集中在本帖中归纳一下有关问题. FormAuthenticationFilter 表单过滤器 表单过 ...
- 2014.04.16,读书,读书笔记-《Matlab R2014a完全自学一本通》-第17章 图形用户界面
界面对象分三类: 用户控件对象(uicontrol) 下拉式菜单对象(uimenu) 内容式菜单对象(uicontextmenu) 创建用户界面: 1.命令行方式 采用uicontrol来创建控件对象 ...
- Codeforces Gym 100015F Fighting for Triangles 状态压缩DP
F Fighting for Triangles Description Andy and Ralph are playing a two-player game on a triangular bo ...
- mysqli的简单工具包
mysqli的简单工具包 <?php /** * 连接 * @param string $host * @param string $user * @param string $password ...
- poj--3159--Candies(简单差分约束)
Candies Time Limit: 1500MS Memory Limit: 131072K Total Submissions: 26888 Accepted: 7398 Descrip ...
- 【POJ 2482】 Stars in Your Windows
[题目链接] http://poj.org/problem?id=2482 [算法] 线段树 + 扫描线 [代码] #include <algorithm> #include <bi ...