POJ 2352 Stars 树阵
标题效果:特定y值在升序一些点。一个点的定义level值点的数目对于其左下,每个请求level多少分。
思维:因为y值它是按升序。所以分的差距仅仅是推断x值相比之前的大。就用树状数组维护。
CODE:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MAX 50000
using namespace std; int cnt,fenwick[MAX];
int ans[MAX]; inline void Initialize();
inline void Fix(int x);
inline int GetSum(int x); int main()
{
while(scanf("%d",&cnt) != EOF) {
Initialize();
for(int x,y,i = 1;i <= cnt; ++i) {
scanf("%d%d",&x,&y);
x++;
Fix(x);
ans[GetSum(x)]++;
}
for(int i = 1;i <= cnt; ++i)
printf("%d\n",ans[i]);
}
return 0;
} inline void Initialize()
{
memset(fenwick,0,sizeof(fenwick));
memset(ans,0,sizeof(ans));
} inline void Fix(int x)
{
for(;x < MAX;x += x&-x)
fenwick[x]++;
} inline int GetSum(int x)
{
int re = 0;
for(;x;x -= x&-x)
re += fenwick[x];
return re;
}
版权声明:本文博客原创文章。博客,未经同意,不得转载。
POJ 2352 Stars 树阵的更多相关文章
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
- POJ 2352 Stars(线段树)
题目地址:id=2352">POJ 2352 今天的周赛被虐了. . TAT..线段树太渣了..得好好补补了(尽管是从昨天才開始学的..不能算补...) 这题还是非常easy的..维护 ...
- POJ 2352 Stars(树状数组)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 30496 Accepted: 13316 Descripti ...
- 【树状数组】POJ 2352 Stars
/** * @author johnsondu * @time 2015-8-22 * @type Binary Index Tree * ignore the coordinate of y and ...
- hdu 1541/poj 2352:Stars(树状数组,经典题)
Stars Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- [POJ] 2352 Stars [线段树区间求和]
Stars Description Astronomers often examine star maps where stars are represented by points on a pla ...
- POJ 2352 Stars(树状数组)题解
Language:Default Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 52268 Accepted: 22 ...
- POJ 2352 stars (树状数组入门经典!!!)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 54352 Accepted: 23386 Descripti ...
- 树状数组 || POJ 2352 Stars
Astronomers often examine star maps where stars are represented by points on a plane and each star h ...
随机推荐
- 开发腾讯移动游戏平台SDK Android版Ane扩展 总结
本文记录了在开发 腾讯移动游戏平台SDK(MSDK) Android版Ane扩展 过程中所遇到的问题和相关解决方式 问题一:编译报错:Unable to resolve target 'android ...
- POJ 2676/2918 数独(dfs)
思路:记录每行每列每一个宫已经出现的数字就可以.数据比較弱 另外POJ 3074 3076 必须用剪枝策略.但实现较麻烦,还是以后学了DLX再来做吧 //Accepted 160K 0MS #incl ...
- 【翻译】我钟爱的Visual Studio前端开发工具/扩展
原文:[翻译]我钟爱的Visual Studio前端开发工具/扩展 怎么样让Visual Studio更好地编写HTML5, CSS3, JavaScript, jQuery,换句话说就是如何更好地做 ...
- SVN基于Maven的Web项目更新,本地过程详细解释
周围环境 MyEclipse:10.7 Maven:3.1.1 概要 最近在做项目,MyEclipse下载SVN基于上述Maven的Web问题,有时候搞了非常半天,Maven项目还是出现叉号,最后总结 ...
- HDU - 2825 Wireless Password(AC自己主动机+DP)
Description Liyuan lives in a old apartment. One day, he suddenly found that there was a wireless ne ...
- swift 新功能介绍
原文链接:http://www.cocoachina.com/applenews/devnews/2014/0617/8857.html 假设你和我一样,准备好好看看苹果的 Keynote,兴奋地准备 ...
- HUNNU11352:Digit Solitaire
Problem description Despite the glorious fall colors in the midwest, there is a great deal of time t ...
- sublime text 2安装及使用
1.首先下载Sublime Text:http://www.sublimetext.com/ 2.基本设置.參考此文:http://blog.jobbole.com/40660/ { "au ...
- android平台TextView使用ImageSpan画廊GIF图像
android-gif-drawable(https://github.com/koral--/android-gif-drawable/releases)开源项目---是一个蛮不错的android ...
- Callable 获取线程返回值
allable与 Future 两功能是Java在兴许版本号中为了适应多并法才增加的,Callable是类似于Runnable的接口,实现Callable接口的类和实现Runnable的类都是可被其它 ...