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. 在ASP.NET MVC中验证checkbox 必须选中 (Validation of required checkbox in Asp.Net MVC)

    转载自 http://blog.degree.no/2012/03/validation-of-required-checkbox-in-asp-net-mvc/ Why would you want ...

  2. Codeforces 597C. Subsequences (树状数组+dp)

    题目链接:http://codeforces.com/contest/597/problem/C 给你n和数(1~n各不同),问你长为k+1的上升自序列有多少. dp[i][j] 表示末尾数字为i 长 ...

  3. servlet-3_0-final-spec

    <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns="http://w ...

  4. Top 7 Myths about HTTPS

    Myth #7 – HTTPS Never Caches People often claim that HTTPS content is never cached by the browser; p ...

  5. Heritrix 3.1.0 源码解析(三十七)

    今天有兴趣重新看了一下heritrix3.1.0系统里面的线程池源码,heritrix系统没有采用java的cocurrency包里面的并发框架,而是采用了线程组ThreadGroup类来实现线程池的 ...

  6. 建表的sql

    1. 创建用户表 create table user( id int unsigned not null primary key auto_increment comment '自增id', user ...

  7. Java日期格式化

    翻译人员: 铁锚 翻译时间: 2013年11月17日 原文链接:   Simple example to show how to use Date Formatting in Java 代码示例如下, ...

  8. MES取所有部门的函数实例

    USE [ChangHong]GO/****** Object: UserDefinedFunction [dbo].[FN_GetDeptCode] Script Date: 04/26/2016 ...

  9. Mysql用户密码设置修改和权限分配

    我的mysql安装在c:\mysql 一.更改密码 第一种方式: 1.更改之前root没有密码的情况 c:\mysql\bin>mysqladmin -u root password " ...

  10. ST10 Bootstrap Loader

    Bootstrap Loader The built-in bootstrap loader (BSL) of the ST10F269 provides a mechanism to load th ...