标题效果:特定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. expdp时遇到ORA-31693&amp;ORA-02354&amp;ORA-01466

    expdp时遇到ORA-31693&ORA-02354&ORA-01466 对一个schema运行expdp导出,expdp命令: nohup expdp HQ_X1/HQ_X1 DU ...

  2. 解决windows下的mysql匿名登陆无法使用mysql数据库的问题

    原文:解决windows下的mysql匿名登陆无法使用mysql数据库的问题 我在windows下安装了mysql,但是不用密码就能登进去,而root明明是有密码的,我用select user()命令 ...

  3. 该项目的建设maven片:4.协调和依赖,spring依赖注入demo

    源码下载 协调 <groupId>com.demo.animal</groupId> <artifactId>animal-core</artifactId& ...

  4. poj2253(最短路小变形)

    题目连接:http://poj.org/problem?id=2253 题意:给出一个无向图,求一条1~2的路径使得路径上的最大边权最小. 分析:dij将距离更新改成取最大值即可,即dp[i]表示到达 ...

  5. 复习面向对象的OOA、OOD、OOP

    复习 OOA.OOD.OOP OOA Object-Oriented Analysis:面向对象分析方法 是在一个系统的开发过程中进行了系统业务调查以后,依照面向对象的思想来分析问题. OOA与结构化 ...

  6. 从尾到头打印链表--《剑指offer》

    题目:非常easy,就是题目,将链表从尾到头打印出来. 可能我们首先想到的是将链表进行遍历,将之前的訪问的数据进行保存,最后进行反向输出,但是保存数据的空间是个问题:或者是我们将整个链表进行反向操作, ...

  7. xcode target

    A target specifies a product to build and contains the instructions for building the product from a ...

  8. SQL Syscolumns

    每个表和视图中的每列在表中占一行,存储过程中的每个参数在表中也占一行.该表位于每个数据库中. 列名 数据类型 描述 name sysname 列名或过程参数的名称. id int 该列所属的表对象 I ...

  9. selenium通过WebDriverWait实现ajax测试

    selenium通过WebDriverWait实现ajax测试 AndroidDriver driver = new AndroidDriver(); driver.get("http:// ...

  10. MyBatis一级缓存引起的无穷递归

    MyBatis一级缓存引起的无穷递归 引言: 最近在项目中参与了一个领取优惠劵的活动,当多个用户领取同一张优惠劵的时候,使用了数据库锁控制并发,起初的设想是:如果多个人同时领一张劵,第一个到达的人领取 ...