POJ——T2352 Stars】的更多相关文章

http://poj.org/problem?id=2352 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 46592   Accepted: 20096 Description Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinat…
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时则按照横坐标从小到大输出. (0 <= x, y <= 32000) 要求输出等级0到n-1之间各等级的星星个数. 分析: 这道题不难想到n平方的算法,即从纵坐标最小的开始搜,每次找它前面横坐标的值比它小的点的个数,两个for循环搞定,但是会超时. 所以需要用一些数据结构去优化,主要是优化找 横坐…
id=2482" target="_blank" style="">题目链接:poj 2482 Stars in Your Window 题目大意:平面上有N个星星.问一个W∗H的矩形最多能括进多少个星星. 解题思路:扫描线的变形.仅仅要以每一个点为左上角.建立矩形,这个矩形即为框框左下角放的位置能够括到该点,那么N个星星就有N个矩形,扫描线处理哪些位置覆盖次数最多. #include <cstdio> #include <cstr…
POJ 2482 Stars in Your Window 题目链接 题意:给定一些星星,每一个星星都有一个亮度.如今要用w * h的矩形去框星星,问最大能框的亮度是多少 思路:转化为扫描线的问题,每一个星星转化为一个矩形,那么等于求矩形相交区域值最大的区域,利用线段树去维护就可以 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long…
[poj P2482] Stars in Your Window Time Limit: 1000MS  Memory Limit: 65536K Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago…
Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30496   Accepted: 13316 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 st…
Stars in Your Window Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13196   Accepted: 3609 Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beaut…
题目链接:http://poj.org/problem?id=2482 读完题干不免有些心酸(…
Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4052    Accepted Submission(s): 1592 Problem Description Astronomers often examine star maps where stars are represented by points on a plan…
Stars in Your Window   Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walk…
Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 41521   Accepted: 18100 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 st…
Stars 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 st…
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. As…
Description Here comes the problem: Assume the sky is a flat plane. All the stars lie on it with a location (x, y). for each star, there is a grade ranging from 1 to 100, representing its brightness, where 100 is the brightest and 1 is the weakest. T…
/** * @author johnsondu * @time 2015-8-22 * @type Binary Index Tree * ignore the coordinate of y and * process as 1D conditions. * @url http://poj.org/problem?id=2352 */ #include <iostream> #include <cstdio> #include <cmath> #include <…
Language:Default Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 52268 Accepted: 22486 Description Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the…
Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 54352   Accepted: 23386 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 st…
[题目链接] http://poj.org/problem?id=2482 [题目大意] 给出一些点的二维坐标和权值,求用一个长H,宽W的矩形能框住的最大权值之和, 在矩形边缘的点不计算在内 [题解] 我们计算能扫到这个点的区间范围,将其拆分为两条平行于y轴的左闭右开的直线, 为方便边界处理,我们将坐标扩大两倍,之后我们按照x轴对这些线段进行扫描 统计出现的最大值即可. [代码] #include <cstdio> #include <algorithm> #include <…
遇见poj上最浪漫的题目..题目里图片以上几百词为一篇模板级英文情书.这情感和细腻的文笔深深地打动了我..不会写情书的童鞋速度进来学习.传送门 题意:坐标系内有n个星星,每个星星都有一个亮度c (1<= c <= 100),坐标和亮度都已给出. 有一个矩形的窗户(就是个理想化的矩形),四条边与x轴或y轴平行.矩形可以在坐标系内平移,但不可以进行旋转操作.求这个矩形可以框住的星星的亮度之和最大为多少.注意:恰好在边上的星星不算在内. 思路:好吧,这题又是看别人的题解才做出来的,深深自责中...思…
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 wa…
题目地址:id=2352">POJ 2352 今天的周赛被虐了. . TAT..线段树太渣了..得好好补补了(尽管是从昨天才開始学的..不能算补...) 这题还是非常easy的..维护信息是每个横坐标的出现的次数. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #inclu…
题目链接 题意:在一个二维平面上有n个星星,每个星星的等级为x,x为该星星左方和下方所包含的星星的数量(包含正左和正下的),输出每个等级各有多少星星,星星坐标按照y序递增给出,y值相同按照x递增给出. 题解:因为已经排好序了,我们每次更新加查询就可以了,因为后加入的一定是下方或者同行的,查询一下是不是左面的就行了.可以用线段树或者树状数组做,注意建树是N不是n,区间更新问题好像可以用什么lazy标记,这道题主要考察的还是思路.注意本题是按照值来进行查询的,建树的时候要用N建树. #include…
转载自 http://www.cnblogs.com/fenshen371/archive/2013/07/25/3214927.html 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时则按照横坐标从小到大输出. (0 <= x, y <= 32000) 要求输出等级0到n-1之间各等级的星星个数.详细信息点击进入传送门. 思路:这个题目数据的输出顺序给了很大的便利.由于是按照纵坐标从小…
该题和 黑书 P102 采矿 类似 参考链接:http://blog.csdn.net/shiqi_614/article/details/7819232http://blog.csdn.net/tsaid/article/details/6686907http://www.cnblogs.com/372465774y/archive/2012/07/28/2613272.html 题意: 给你10000以内的星星的坐标和星星的亮度(即分别为x,y,c),要求用W*H的矩形去围住一个区域, 使得…
题意:有一堆星星,每个星星的级别为坐标不高于它且不在它右边的星星个数,求级别为0-n - 1的星星个数. 解法:树状数组.输入的星星坐标已经按y坐标升序排序,y坐标相等的按x升序排序,所以每输入一个数只要看之前输入的星星里有几个x坐标小于等于它的x坐标即为它的等级,等级计数器加一,把这个星星的x坐标加入树状数组,最后扫一遍等级计数器输出.并没注意到x坐标有0这种坑爹的事情……果断T了…… 代码: #include<stdio.h> #include<iostream> #inclu…
标题效果:特定y值在升序一些点.一个点的定义level值点的数目对于其左下,每个请求level多少分. 思维:因为y值它是按升序.所以分的差距仅仅是推断x值相比之前的大.就用树状数组维护. CODE: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define MAX 50000 using namespace std; int cnt,fenwi…
线段树+离散化+扫描线 AC之后,又认真读了一遍题目,好文章. #include<cstdio> #include<map> #include<algorithm> using namespace std; +; int n; long long W,H; long long x[maxn],y[maxn],v[maxn]; struct seg { long long X; long long Y1,Y2; long long val; }s[*maxn]; stru…
<题目链接> 题目大意: 题目给出n个点,这些点按照y坐标的升序,若y相同,则按照x的升序顺序输入,问,在这些点中,左下角的点的数量分别在0~n-1的点分别有多少个,写出它们的对应点数.  解题分析: 因为所有点是按照y坐标的升序优先给出,所以后面的点y坐标一定大于等于前面的.于是,判断该点前面有多少点满足在该点的“左下角”,只需看前面的点有几个x坐标小于当前点即可,所以,我们只需要对x坐标建一维树状数组即可求解. #include <cstdio> #include <cs…
题目 题意:按y递增的顺序给出n颗星星的坐标(y相等则x递增),每个星星的等级等于在它左边且在它下边(包括水平和垂直方向)的星星的数量,求出等级为0到n-1的星星分别有多少个. 因为y递增的顺序给出,于是乎这道题跟 y 无关,在每次输入x的时候都去判断比x小,即在x之前的数有多少(ans)个,即星星的等级.然后更新num[ans]++  ( 存ans等级星星的个数num[ans]++ ). 刚开始觉得x不是值吗,怎么一会又变成下标了.其实x一直都是下标,既是题中坐标系的下标,也是树状数组中的下标…
题目大意: 求一个窗体覆盖最多的星星的权值. 思路分析: 每个星星看成 左下点为x y 右上点为x+w-1 y+h-1 的矩形. 然后求出最大覆盖的和. #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #define lson num<<1,s,mid #define rson num<<1|1,mid+1,e #define…