Poj2482 Stars in Your Window(扫描线)】的更多相关文章

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 walking out of the classroom and turned…
id=2482" target="_blank" style="">题目链接:poj 2482 Stars in Your Window 题目大意:平面上有N个星星.问一个W∗H的矩形最多能括进多少个星星. 解题思路:扫描线的变形.仅仅要以每一个点为左上角.建立矩形,这个矩形即为框框左下角放的位置能够括到该点,那么N个星星就有N个矩形,扫描线处理哪些位置覆盖次数最多. #include <cstdio> #include <cstr…
Stars in Your Window Language:Default Stars in Your Window Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15036 Accepted: 4061 Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I sti…
题面 Poj 题解 下面内容引用自"李煜东 <算法竞赛进阶指南>"(对原文略有缩减,侵删): 因为矩形的大小固定,所以矩形可以由它的任意一个顶点唯一确定.我们可以考虑把矩形的右上角顶点放在什么位置,圈住的星星亮度总和最大. 所以,对于一颗星星,能够覆盖住这颗星星的右上角的位置在区间\([x,y]-[x+w,y+h]\)之间,但是由于边界上的星星不算,所以不妨将星星变为\([x-0.5,y-0.5]\),于是右上角变为\([x+w-1,y+h-1]\). 问题就转化成了:平面…
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 walking out of the classroom and turned…
此题可用线段树或静态二叉树来做. 考虑用线段树: 很容易想到先限定矩形横轴范围再考虑在此纵轴上矩形内物品总价值的最大值. 那么枚举矩形横轴的复杂度是O(n)的,考虑如何快速获取纵轴上的最大值. 我们不可能再次枚举纵轴,依次统计,这样做事多余的. 考虑窗口在纵轴上的滑动,每上升到一个新的高度,在加入新元素的同时只需将最底层的那些值弹出队列即可. 这样我们需要考虑队列上元素和的最大值. 我们从反面考虑每个元素对特定队列(矩形纵轴位置)的贡献. 枚举窗口的上面一条边,那么元素对窗口贡献正值当且仅当H(…
Stars in Your Window Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11706   Accepted: 3183 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…
[POJ2482]Stars in Your Window 题面 vjudge 题解 第一眼还真没发现这题居然™是个扫描线 令点的坐标为\((x,y)\)权值为\(c\),则 若这个点能对结果有\(c\)的贡献,必须要矩形左下角的点的范围必须在\(([x,x+w),[y,y+h))\)之间 则按扫描线套路将一个类似矩形的范围拆成线\((x,y1,y2,c)\).\((x+w,y1,y2,-c)\)(依次表示横坐标.下端点纵坐标.上端点纵坐标.权值)即可 最后注意排序时不但要按\(x\)排,也要按…
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…
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 walking out of the classroo…