题目

Stars
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 34016   Accepted: 14839

Description

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

  1. 5
  2. 1 1
  3. 5 1
  4. 7 1
  5. 3 3
  6. 5 5

Sample Output

  1. 1
  2. 2
  3. 1
  4. 1
  5. 0

Hint

This problem has huge input data,use scanf() instead of cin to read data to avoid time limit exceed.

Source

题解

题目大意:在一片苍茫的大海上,有很多很多明亮的星星【他们一共有N个】,他们经常相互追逐,每个星星都可以干掉他们左下角之内的星星,请统计能干掉0~N-1个星星的数量。我写不下去了【=_=||其实我不懂英文,前面都是我瞎翻译的。】其实-有N个星星(X0,Y0),每个星星的等级为其左下角的星星的数量,统计不同level的星星的数量。并从0~N-1输出。

用树状数组统计每个x之前的星星的数量,并将星星在x位置插入。注意处理x可能等于0的情况。

代码

  1. Stars
  2. Time Limit: 1000MS Memory Limit: 65536K
  3. Total Submissions: Accepted:
  4.  
  5. Description
  6.  
  7. 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.
  8.  
  9. For example, look at the map shown on the figure above. Level of the star number is equal to (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.
  10.  
  11. You are to write a program that will count the amounts of the stars of each level on a given map.
  12. Input
  13.  
  14. The first line of the input file contains a number of stars N (<=N<=). The following N lines describe coordinates of stars (two integers X and Y per line separated by a space, <=X,Y<=). 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.
  15.  
  16. Output
  17.  
  18. The output should contain N lines, one number per line. The first line contains amount of stars of the level , the second does amount of stars of the level and so on, the last line contains amount of stars of the level N-.
  19. Sample Input
  20.  
  21. Sample Output
  22.  
  23. Hint
  24.  
  25. This problem has huge input data,use scanf() instead of cin to read data to avoid time limit exceed.
  26. Source
  27.  
  28. Ural Collegiate Programming Contest

POJ2352:Stars的更多相关文章

  1. POJ2352:Stars——题解

    http://poj.org/problem?id=2352 Astronomers晚上仰望星空,看到了很多星星.回到办公桌,Astronomers将这些星星画到二维坐标系,每个星星的坐标都是整数.例 ...

  2. 用Python作GIS之二:STARS开发环境配置

    STARS的一般使用可以通过REGAL网页快速学习http://regionalanalysislab.org/?n=STARS再次不做详细介绍这里关注的主题是对STARS源代码分析即为使用Pytho ...

  3. 51nod 1208 && POJ 2482:Stars in Your Window

    1208 Stars in Your Window 题目来源: Poj 基准时间限制:2 秒 空间限制:131072 KB 分值: 160 难度:6级算法题  收藏  取消关注 整点上有N颗星星,每颗 ...

  4. HDU - 5126: stars (求立方体内点数 CDQ套CDQ)

    题意:现在给定空空的三维平面,有加点操作和询问立方体点数. 思路:考虑CDQ套CDQ.复杂度是O(NlogN*logN*logN),可以过此题. 具体的,这是一个四维偏序问题,4维分别是(times, ...

  5. POJ - 2482:Stars in Your Window (扫描线 )

    题意:二维平面上给你N颗星,给出星星的坐标,亮度: 然后给你一个W*H的窗口,问你最大的亮度和. 思路:扫描线,假设有一个inf*H的窗口,按照y排序,那么就把H范围内的星星放入了这个窗口(单调队列实 ...

  6. 用Python作GIS之一:介入STARS

    STARS的全称是Space-Time Analysis of Regional Systems,直译过来就是区域系统时空分析软件.这是针对区域多时相数据的分析包,源代码公开.该软件将最近几年发展起来 ...

  7. NeHe OpenGL教程 第九课:移动图像

    转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...

  8. R语言学习笔记:基础知识

    1.数据分析金字塔 2.[文件]-[改变工作目录] 3.[程序包]-[设定CRAN镜像] [程序包]-[安装程序包] 4.向量 c() 例:x=c(2,5,8,3,5,9) 例:x=c(1:100) ...

  9. 前端每日实战:96# 视频演示如何用纯 CSS 和 D3 创作一艘遨游太空的宇宙飞船

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/oMqNmv 可交互视频 此视频是可 ...

随机推荐

  1. Mysql动态多条件查询

    动态多条件查询是一类经常遇到的问题. 在Mysql里面可以用语句简单的解决. SELECT * FROM product WHERE price = IF('{0}' = '', price, '{0 ...

  2. 在不同编程语言中对Unix时间戳进行转换(Unix timestamp)

    最近用到unix时间转换在mysql和.net中的应用.将此资料保存在博客中. 如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)? Java time JavaScript ...

  3. Ubuntu12.04 配置Java开发环境:JDK1.7+Eclipse+Tomcat7.0

    软硬件环境 Ubuntu12.04+JDK1.7+Eclipse+Tomcat7.0 内容列表 1.安装JDK1.7,配置JAVA环境 2.安装Eclipse 3.安装Tomcat7.0 1.安装JD ...

  4. Microsoft.AlphaImageLoader滤镜讲--透明处理<转>

    Microsoft.AlphaImageLoader是IE滤镜的一种,其主要作用就是对图片进行透明处理.虽然FireFox和IE7以上的IE浏览器已经支持透明的PNG图片,但是就IE5-IE6而言还是 ...

  5. MFC CArchive实现保存到二进制文件

    先看一下效果图 BOOL Save2File() { BOOL bOpenFileDialog = FALSE; ---------------------------------- ① BOOL b ...

  6. TF卡速度测试对比 Class数越高速度越快

    存储卡(TF卡)是手机扩展存储的大杀器,让你多装n部学习资料,多装n个外语听力练习.除了装东西外,存储卡性能不佳也会影响手机的整体性能以及体验的.本文主要针对Android手机,我是懒人,但我讨厌懒人 ...

  7. 一个基于Qt的截屏程序

    最近有一个arm板上的程序需要重写用户手册,在网上找了许久,没找到合适的截屏工具.于是只好自己动手做一个了. 因为arm板上有已经有了Qt环境,于是想到用 Qt的QPixmap::grabWindow ...

  8. select option 下拉多选单选bootstrap插件使用总结2

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. 在Mac上配置Apache+PHP环境

    1.启用Apache/Web共享 打开终端,运行启动Apache命令: sudo apachectl start 然后输入系统密码,运行成功. 关闭命令: sudo apachectl stop 重启 ...

  10. java中的上传下载----ajaxFileUpload+struts2

    文件上传在项目中应该是非常常见的,而且很多时候,上传文件都只是一个小页面中的一个功能,要求在实现文件上传的前提下不刷新页面.而一般情况下将客户端的文件包装成网络地址传递到服务器端然后通过流来进行文件传 ...