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的..维护 ...
随机推荐
- JAVA之经典算法
package Set.Java.algorithm; import java.util.Scanner; public class algorithm { /** * [程序1] 题目:古典问题:有 ...
- 使用MVCPager做AJAX分页所需要注意的地方
1.版本问题,推荐使用2.0以上,对ajax支持才比较的好了 2.当需要使用页索引输入或下拉框以及使用Ajax分页模式时,必须用Html.RegisterMvcPagerScriptResource方 ...
- node.js中的http.response.end方法使用说明
转载自:http://m.jb51.net/article/58468.htm 本文介绍了http.response.end的方法说明.语法.接收参数.使用实例和实现源码,需要的朋友可以参考下 方法说 ...
- Redis 个人理解总结
一.什么是Redis ? Redis(remote dictionnary server)是一个key-value存储系统.Redis是一个开源的使用ANSI C语言编写.遵守BSD协议.支持网络.可 ...
- .net unicode汉字互相转换
[两种方法].net unicode汉字互相转换 ========================================= //汉字转Unicode编码(ASCII) private str ...
- Mysql一些常用语句
1.查询表创建的时间: SELECT CREATE_TIME FROM INFORMATION_SCHEMA.TABLES WHERETABLE_NAME='TableName'
- java io 好文传送
转自:白大虾 地址:https://www.cnblogs.com/baixl/p/4170599.html 主要内容 java.io.File类的使用 IO原理及流的分类 文件流 FileInput ...
- XML.libXml2_ZC
1.字符串比较函数: xmlStrcmp(...) 这是大小写敏感的比较 xmlStrcasecmp(...) 这是大小写不敏感的比较(忽略字符串里面字符的大小写) 2.查找节点 2.1.循环 2.2 ...
- [原][粒子特效][spark]调节器modifier
深入浅出spark粒子特效连接:https://www.cnblogs.com/lyggqm/p/9956344.html group添加modifier的方式: modifier An abstra ...
- 力扣(LeetCode)520. 检测大写字母
给定一个单词,你需要判断单词的大写使用是否正确. 我们定义,在以下情况时,单词的大写用法是正确的: 全部字母都是大写,比如"USA". 单词中所有字母都不是大写,比如"l ...