题意:给出n个平面二维坐标,对于每个坐标,如果这个坐标跟(0,0)形成的矩形内包含的点数为 k (包含边界,但不包含坐标本身),那么这个坐标就是 level k。输出level 0 - n-1的点数分别是多少。

思路:树状数组,线段树  稍后写一个线段树版本

#include <stdio.h>
#include <string.h>
#define N 15005
#define M 32005
int c[M], s[N];
int ans[N];
int n, max ,y;
int lowbit(int x)
{
return x&(-x);
} int sum(int x)
{
int sum=;
while(x>)
{
sum+=c[x];
x-=lowbit(x);
}
return sum;
} void change(int x,int val)
{
while(x<=max+)
{
c[x]+=val;
x+=lowbit(x);
}
} int main()
{
// freopen("in.txt", "r", stdin);
scanf("%d", &n);
max = ;
for(int i=; i<=n; i++)
{
scanf("%d%d", &s[i], &y);
max = s[i] > max ? s[i] : max;
}
memset(ans, , sizeof(ans));
for(int i=; i<=n; i++)
{
ans[sum(s[i]+)]++;
change(s[i]+,);
}
for(int i=;i<n;i++)
printf("%d\n", ans[i]);
return ;
}

【树状数组】 poj 2352的更多相关文章

  1. 树状数组 || POJ 2352 Stars

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

  2. 线段树/树状数组 POJ 2182 Lost Cows

    题目传送门 题意:n头牛,1~n的id给它们乱序编号,已知每头牛前面有多少头牛的编号是比它小的,求原来乱序的编号 分析:从后往前考虑,最后一头牛a[i] = 0,那么它的编号为第a[i] + 1编号: ...

  3. 树状数组 || POJ 3321 Apple Tree

    一道dfs序+树状数组的题 因为并没有get到dfs序以及对树状数组也不熟练卡了很久orz dfs序: in和out是时间戳 dfs序可以将树转化成为一个序列,满足区间 -> 子树 然后就可以用 ...

  4. LCA+树状数组 POJ 2763 Housewife Wind

    题目传送门 题意:两种操作,问u到v的距离,并且u走到了v:把第i条边距离改成w 分析:根据DFS访问顺序,将树处理成链状的,那么回边处理成负权值,那么LCA加上BIT能够知道u到v的距离,BIT存储 ...

  5. 树状数组 POJ 2481 Cows

    题目传送门 #include <cstdio> #include <cstring> #include <algorithm> using namespace st ...

  6. POJ 2352 Stars(树状数组)

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

  7. POJ 2352 &amp;&amp; HDU 1541 Stars (树状数组)

    一開始想,总感觉是DP,但是最后什么都没想到.还暴力的交了一发. 然后開始写线段树,结果超时.感觉自己线段树的写法有问题.改天再写.先把树状数组的写法贴出来吧. ~~~~~~~~~~~~~~~~~~~ ...

  8. 【树状数组】POJ 2352 Stars

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

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

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

  10. POJ 2352 【树状数组】

    题意: 给了很多星星的坐标,星星的特征值是不比他自己本身高而且不在它右边的星星数. 给定的输入数据是按照y升序排序的,y相同的情况下按照x排列,x和y都是介于0和32000之间的整数.每个坐标最多有一 ...

随机推荐

  1. How to set a MySQL root user password in MAC OSX

    https://www.youtube.com/watch?v=sFT9tGL54sI

  2. ios导航栏又按钮添加图片后使其保持原色

    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStyl ...

  3. Handling Captcha | Webdriver

    http://seleniumworks.blogspot.kr/2013/09/handling-captcha-webdriver.html Make use of the 'input' tag ...

  4. css在网页中划线

    在行边距上的线可以通过 1 div,表格等的border属性实现 2 <hr/>实现 3 通过背景图片实现 4 页面内写入横线图片 通过相对定位实现 5 通过css伪类实现 <sty ...

  5. hdu_2147_kiki's game(博弈)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2147 题意:给你一个矩阵,从右上走到左下,每次只能向左或向下或向斜下走一格,先走到最后一格的会输,问k ...

  6. 解决centos网速特别慢的最佳解决办法

    摘自:http://www.centoscn.com/CentosBug/osbug/2014/0614/3138.html 我使用了centOS,但是发现网速实在是卡得几乎不能上网,连百度都打不开, ...

  7. subversion SVN global ignore pattern

    *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store */bin */ ...

  8. go share library

    http://blog.ralch.com/tutorial/golang-sharing-libraries/ Sharing Golang packages to C and Go Sun, Au ...

  9. Hibernate主键生成方式之hilo

    当利用Hibernate的getHibernateTemplate().save(obj);插入的对象的主键ID为null的时候自动生成5位数的主键ID进行插入. 此笔记的由来: 老夫在此处上传材料后 ...

  10. win8.1下安装ubuntu 14.0 4LTS

    1.前奏 电脑上已经安装了win8.1系统 2.准备工作 关闭win8.1的快速启动 步骤: 控制面板->电源选项->选择电源按钮的功能->更改不可用的设置,然后把"启用快 ...