标题效果:特定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 树阵的更多相关文章

  1. poj 2352 Stars 数星星 详解

    题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...

  2. POJ 2352 Stars(线段树)

    题目地址:id=2352">POJ 2352 今天的周赛被虐了. . TAT..线段树太渣了..得好好补补了(尽管是从昨天才開始学的..不能算补...) 这题还是非常easy的..维护 ...

  3. POJ 2352 Stars(树状数组)

    Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30496   Accepted: 13316 Descripti ...

  4. 【树状数组】POJ 2352 Stars

    /** * @author johnsondu * @time 2015-8-22 * @type Binary Index Tree * ignore the coordinate of y and ...

  5. hdu 1541/poj 2352:Stars(树状数组,经典题)

    Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  6. [POJ] 2352 Stars [线段树区间求和]

    Stars Description Astronomers often examine star maps where stars are represented by points on a pla ...

  7. POJ 2352 Stars(树状数组)题解

    Language:Default Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 52268 Accepted: 22 ...

  8. POJ 2352 stars (树状数组入门经典!!!)

    Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 54352   Accepted: 23386 Descripti ...

  9. 树状数组 || POJ 2352 Stars

    Astronomers often examine star maps where stars are represented by points on a plane and each star h ...

随机推荐

  1. Linux下Apache PHP Mysql默认安装路径

    Apache 假设採用RPM包安装.安装路径应在 /etc/httpd文件夹下 Apache配置文件: /etc/httpd/conf/httpd.conf Apache模块路径: /usr/sbin ...

  2. asp.net中用FileStream类实现下载文件功能,自定义下载路径,像IE下载一样

    方法一: //这个值可以从配置文件读取,或者放个textbox让用户填 string path = "你的路径";FileStream outputStream = new Fil ...

  3. A Game of Thrones(9) - Tyrion

    Somewhere in the great stone maze(迷宫:迷惑) of Winterfell, a wolf howled. The sound hung over the castl ...

  4. 【微信公众平台开发】公布动态新闻好帮手UEditor富文本

    因为微信要做公布动态新闻.那就须要富文本. 上网搜索有非常多这样的插件,比方CKEditor.KindEditor等:最后看到百度一款开源的UEditor.官网打开,风格设计就吸引住了自己.所以就选U ...

  5. Python什么是二次开发的意义?python在.net项目采用

    任何人都知道python在.net该项目是做什么的啊? 辅助用途,用作"二次开发"..net站点的话python主要是CGI才用.能够用python编写B/S程序. 解释一下二次开 ...

  6. getline与get函数的区别

    get()函数相对getline来说使用方法要灵活的多了. 1.   int get()是指从流中抽取单个字符并返回,这个是没有參数的形式.由于c++不像c语言使用getchar() 2.istrea ...

  7. Cordova CLI源码分析(二)——package.json

    每个包需要在其顶层目录下包含一个package.json文件,该文件不仅是包的说明,也影响npm安装包时的配置选项 更多参数详见参考文档https://npmjs.org/doc/json.html ...

  8. Macosx Setdns

    通过C语言接口在Mac App内部对系统的DNS配置进行改动. Mac OS X设置DNS代码 演示样例代码setDNS.c内容例如以下: #include <SystemConfigurati ...

  9. Android开发工具综述,开发人员必备工具

    安卓开发工具汇总.开发者必备.安卓开发过程中须要用到各种工具,作为一名安卓开发者,有木有感到亚历山大,那么多工具! 今天给大家汇总了一下安卓开发工具,安卓开发者必备利器. 1.Draw 9-Patch ...

  10. Linux下的下载工具介绍----aria2

    ariac 项目地址:http://aria2.sourceforge.net/ 下载地址:http://sourceforge.net/projects/aria2/files/stable/ari ...