POJ2352:Stars

题目

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

5
1 1
5 1
7 1
3 3
5 5

Sample Output

1
2
1
1
0

Hint

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

Source

Ural Collegiate Programming Contest 1999

题解

题目大意:在一片苍茫的大海上,有很多很多明亮的星星【他们一共有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: 34016  Accepted: 14839
 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
10
11 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.
12
13 You are to write a program that will count the amounts of the stars of each level on a given map.
14 Input
15
16 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.
17
18 Output
19
20 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.
21 Sample Input
22
23 5
24 1 1
25 5 1
26 7 1
27 3 3
28 5 5
29 Sample Output
30
31 1
32 2
33 1
34 1
35 0
36 Hint
37
38 This problem has huge input data,use scanf() instead of cin to read data to avoid time limit exceed.
39 Source
40
41 Ural Collegiate Programming Contest 1999

时间: 2024-08-27 22:49:46

POJ2352:Stars的相关文章

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

STARS的一般使用可以通过REGAL网页快速学习http://regionalanalysislab.org/?n=STARS再次不做详细介绍这里关注的主题是对STARS源代码分析即为使用Python直接从底层开发GIS的过程 STARS 0.8.2版本的下载链接中提供了两种类型:安装包和源代码包安装包可以直接安装运行,而源代码包可以通过Python编辑器编译后运行上述两种操作获得的效果是一样的 下载地址:1.安装包 http://prdownloads.sourceforge.net/sta

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

题意:现在给定空空的三维平面,有加点操作和询问立方体点数. 思路:考虑CDQ套CDQ.复杂度是O(NlogN*logN*logN),可以过此题. 具体的,这是一个四维偏序问题,4维分别是(times,x,y,z):我们知道cdq可以求出t<=T,x=X,y<=Y,在套一层就可以z<=Z了.那么一个立方体,我们拆为8个点来容斥. 然后现在的问题就是,求出(0,0,0)到(x,y,z)的点数. 第一维T已经默认排序了,我们先对X分治. 把所有问题分成两块,并且把左边这块标记o=-1,右边的标

用Python作GIS之一:介入STARS

STARS的全称是Space-Time Analysis of Regional Systems,直译过来就是区域系统时空分析软件.这是针对区域多时相数据的分析包,源代码公开.该软件将最近几年发展起来的时空分析技术引入到友好的用户界面中,设计目标是要成为一款探索性数据分析软件. 不得不说的是,探索性空间数据分析(ESDA)在国内才刚刚起步,而STARS面向的则是更为复杂的探索性时空数据分析(ESTDA).因而,多了解这样一个软件无异可以为国内GIS研究开辟一个新方向. 此软件为圣迭戈州立大学地理

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

转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线教程的编写,以及yarn的翻译整理表示感谢. NeHe OpenGL第九课:移动图像 3D空间中移动图像: 你想知道如何在3D空间中移动物体,你想知道如何在屏幕上绘制一个图像,而让图像的背景色变为透明,你希望有一个简单的动画.这一课将教会你所有的一切.前面的课程涵盖了基础的OpenGL,每一课都是在

R语言与数据分析之二:绘图

图形展示是最高效且形象的数据描述手段,因此巧妙的图像展示是高质量数据分析报告的必备内容,因此强大的图形展示功能也是统计分析软件的必备功能.R语言提供了强大的吐血展示功能.今天我由简单到复杂分别和小伙伴们分享如何用R语言画出各位想要的图形. 首先罗列下所有可选图形: 1.直方图(hist()):2.散点图(plot()):3.柱状图(barplot());4.饼图(pie());5.箱线图(boxplot());6.星相图(stars());7.脸谱图(faces());8.茎叶图(stem())

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

1.数据分析金字塔 2.[文件]-[改变工作目录] 3.[程序包]-[设定CRAN镜像] [程序包]-[安装程序包] 4.向量 c() 例:x=c(2,5,8,3,5,9) 例:x=c(1:100) 表示把1 - 100的所有数字都给x这个变量 5.查看x的类型:>mode(x) 6.查看x的长度:>length(x) 7.将两个向量组成一个矩阵: >rbind(x1, x2)  注:r是row的意思,即行,按行组成矩阵. >cbind(x1, x2)  注c是column的意思,

hdu1541 Stars 树状数组水题

Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5378    Accepted Submission(s): 2125 Problem Description Astronomers often examine star maps where stars are represented by points on a pla

R入门-图表

画直方图:hist(x$x1)  //参数为向量,x为表图 画散点图:plot(x1,x2) // plot(x$x1,x$x2) // 列联表分析: 列联函数table() // table(x$x1) barplot(table(x$x1)) 饼图:pie(table(x$x1)) 箱线图:boxplot(x$x1,x$x2,x$x3) 星相图:stars(x[c("x1","x2","x3")])   //三角形 stars(x[c(&qu

Day14、随处可见的对话框

日常生活中我们随处可见对话框,上面有很多提示信息,更加方便提示用户进行不同的操作. 一.对话框的两个特点和一些常见的对话框 1.当弹出对话框是会结束UI线程(即主线程): 2.当前的Activity会失去焦点: 3.消息对话框.确认对话框.列表对话框.单选和多选对话框.自定义对话框 二.对话框的组成(一般有四部分组成) 1.图标 2.标题 3.内容 4.按钮 三.那么如何创建一个对话框呢?(四步组成) 1.第一步创建AlertDialog.Builder对象(建造者模式) 2.第二步设置图标.标