Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the stars. 

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

The first line of the input file contains a number of stars N (1<=N<=15000). The following N lines describe coordinates of stars (two integers X and Y per line separated by a space, 0<=X,Y<=32000). There can be only one star at one point of the plane. Stars are listed in ascending order of Y coordinate. Stars with equal Y coordinates are listed in ascending order of X coordinate.

 

Output

The output should contain N lines, one number per line. The first line contains amount of stars of the level 0, the second does amount of stars of the level 1 and so on, the last line contains amount of stars of the level N-1.

 

Sample Input

5
1 1
5 1
7 1
3 3
5 5
 

Sample Output

1
2
1
1
0
  1. #include"stdio.h"
  2. #include"string.h"
  3. int c[32005];
  4. int a[32005];
  5. int n;
  6. int lowbit(int x)
  7. {
  8. return x&(-x);
  9. }
  10. void updata(int x,int d)
  11. {
  12. while(x<=32005)
  13. {
  14. c[x]+=d;
  15. x+=lowbit(x);
  16. }
  17. }
  18. long long int getsum(int x)
  19. {
  20. long long int res=0;
  21. while(x>0)
  22. {
  23. res+=c[x];
  24. x-=lowbit(x);
  25. }
  26. return res;
  27. }
  28. int main()
  29. {
  30. int i,x,y;
  31. scanf("%d",&n);
  32. memset(c,0,sizeof(c));
  33. memset(a,0,sizeof(a));
  34. for(i=1;i<=n;i++)
  35. {
  36. scanf("%d%d",&x,&y);
  37. x++;//0<=x,y<=
  38. a[getsum(x)]++;//点已经排好序,记录在X前面的星星 记录同等级的级数
  39. updata(x,1);//记录个数,只要X<=当前点的横坐标
  40. }
  41. for(i=0;i<n;i++)
  42. printf("%d\n",a[i]);
  43. }

star的更多相关文章

  1. 【Star CCM+实例】开发一个简单的计算流程.md

    流程开发在CAE过程中处于非常重要的地位. 主要的作用可能包括: 将一些经过验证的模型隐藏在流程中,提高仿真的可靠性 将流程封装成更友好的界面,降低软件的学习周期 流程开发实际上需要做非常多的工作,尤 ...

  2. github中的watch、star、fork的作用

    [转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...

  3. [deviceone开发]-Star分享的几个示例

    一.简介 这个是star早期分享的几个示例,都非常实用,包括弹出的菜单,模拟支付密码输入等.初学者推荐.也可以直接使用.二.效果图 三.相关下载 https://github.com/do-proje ...

  4. 时隔一年再读到the star

    The Star Arthur C. Clarke It is three thousand light-years to the Vatican. Once, I believed that spa ...

  5. Github上的Watch和 Star的区别

    Github 推出了新的 Notification 系统,更改了原有的 Watch 机制,为代码库增加了 Star 操作.Notification 将接收 Watching 代码库的动态,包括:* I ...

  6. 纯css3 Star

    <style><!--* { box-sizing: border-box; padding: 0px; margin: 0px; } body, html { height: 10 ...

  7. Got the Best Employee of the year 2015 Star Award

    Got "The Best Employee of the year 2015 Star Award" from the company, thanks to all that h ...

  8. star ccm+ 11.02安装

    STAR CCM+是CD-Adapco公司的主打软件,其安装方式较为简单,这里以图文方式详细描述STAR CCM+11.02安装过程. 1 安装准备工作2 正式安装3 软件破解4 软件测试 1 安装准 ...

  9. System.Diagnostics.Process.Star的用法

    System.Diagnostics.Process.Start(); 能做什么呢?它主要有以下几个功能: 1.打开某个链接网址(弹窗). 2.定位打开某个文件目录. 3.打开系统特殊文件夹,如“控制 ...

  10. ACM: FZU 2110 Star - 数学几何 - 水题

     FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Pr ...

随机推荐

  1. Docker进入主流,PaaS大有可为(转)

    add by zhj: 文章简单的说了PaaS所使用的传统容器的缺点,而docker这个容器在一定程度上解决了这些问题,越来越多的PaaS平台使用docker作容器,实现应用的隔离.不过,由于dock ...

  2. 深入剖析AutoreleasePool

    [深入剖析AutoreleasePool] Objc的AutoreleasePool是一个首尾相连的内存链接,每块大小为1页(32位机上为4kb). 上面可以看到,parent指向父Pool,chil ...

  3. 创建类模式(五):单例(Singleton)

    定义 确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例. 单例模式一般情况下通过使用private的构造函数确保了在一个应用中只产生一个实例,并且是自行实例化. 和静态变量的区别 虽然 ...

  4. PLSA中的EM算法

    转自:http://www.cnblogs.com/rocketfan/archive/2011/07/03/2096953.html 主要记录下几个文章博客内容 A Note on EM Algor ...

  5. OC:NSmuber、NSString 的互转

    NSmuber 转化为 IOS 中的 NSString 假设现有一NSNumber的变量A,要转换成NSString类型的B 方法如下: NSNumberFormatter* numberFormat ...

  6. vtk点云数据的显示[转]

    #include "vtkActor.h" #include "vtkRenderer.h" #include "vtkRenderWindow.h& ...

  7. wchar_t 和 char 之间转换

    vc++2005以后,Visual studio 编译器默认的字符集为Unicode.VC中很多字符处理默认为宽字符wchar_t,如CString的getBuffer(),而一些具体操作函数的输入却 ...

  8. 学习JQuery中文文档之index()函数

    最初认识index()是在轮播图中,获取当前点击对象在数组中的位置.那时候,对index()的使用只有eq($(this).index()),看了文档之后,才知道自己有多幼稚! <!DOCTYP ...

  9. XGrid绑定(转)

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Fo ...

  10. pat 1055 区间前k个

    http://pat.zju.edu.cn/contests/pat-a-practise/1055 第二组数据比较大,如果单纯排序直接检索会超时,因为每次都是对所有数据进行遍历. N/200=500 ...