(中等) HDU 1542 Atlantis,扫描线。】的更多相关文章

Problem Description There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe different regions of Atlantis. You…
题目大意就是:去一个地方探险,然后给你一些地图描写叙述这个地方,每一个描写叙述是一个矩形的右下角和左上角.地图有些地方是重叠的.所以让你求出被描写叙述的地方的总面积. 扫描线的第一道题,想了又想,啸爷还给我讲了讲,最终有点理解了啊. 先说扫描线:书上说扫描线不是一个物体.而是一个概念. 在计算几何中的作用类似于图论中的bfs与dfs.所以还是须要多做题目来体会一下啊. 这道题目的做法是:离散化x坐标.然后依照y坐标的大小进行排序,每一条保存它的左边界的位置与右边界的位置.以及自身的高度. 还有就…
n个矩形,可以重叠,求面积并. n<=100: 暴力模拟扫描线.模拟赛大水题.(n^2) 甚至网上一种“分块”:分成n^2块,每一块看是否属于一个矩形. 甚至这个题就可以这么做. n<=100000 这就要到扫描线了. 之前一直不会. 不好处理的地方在于:不知道区间被覆盖怎么计算.... 像sum区间和一样计算??sum>区间长度也不一定完全包含... 不管覆盖多少次,就只算一次??之后的减法怎么算?? 总之, 这篇题解打消了我的疑惑:ACM POJ1151 (HDU 1542) Atl…
HDU 1542 Atlantis 题目链接 题意:给定一些矩形,求面积并 思路:利用扫描线,因为这题矩形个数不多,直接暴力扫就能够了.假设数据大.就要用线段树 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const int N = 205; const int M = 100005; const dou…
Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11551    Accepted Submission(s): 4906 Problem Description There are several ancient Greek texts that contain descriptions of the fabled…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1542 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. So…
Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6116    Accepted Submission(s): 2677 Problem Description There are several ancient Greek texts that contain descriptions of the fabled i…
Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6386    Accepted Submission(s): 2814 Problem Description There are several ancient Greek texts that contain descriptions of the fabled i…
Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8998    Accepted Submission(s): 3856 Problem Description There are several ancient Greek texts that contain descriptions of the fabled i…
题意:给n个可能相交的矩形,问你不重复的总面积 思路:扫描线,一边扫一边加. 扫描线:图片来源:理解扫描线 假设我们要算以下四个矩形面积,显然中间深色的是重复的.我们按照x的大小,从左往右扫,然后用线段树维护y轴向的长度就可以了.但是,我们不能用点去维护y轴坐标,而是抽象成把点i看成y[i]到y[i+1]这个区间,不然会有错. 代码: #include<set> #include<map> #include<stack> #include<cmath> #i…