题目链接:https://vjudge.net/problem/HDU-1255 给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积. Input输入数据的第一行是一个正整数T(1<=T<=100),代表测试数据的数量.每个测试数据的第一行是一个正整数N(1<=N<=1000),代表矩形的数量,然后是N行数据,每一行包含四个浮点数,代表平面上的一个矩形的左上角坐标和右下角坐标,矩形的上下边和X轴平行,左右边和Y轴平行.坐标的范围从0到100000. 注意:本题的输入数据较…
题目链接:https://vjudge.net/problem/HDU-3642 Jack knows that there is a great underground treasury in a secret region. And he has a special device that can be used to detect treasury under the surface of the earth. One day he got outside with the device…
题目链接:https://vjudge.net/problem/HDU-1542 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 reg…
题目链接:https://vjudge.net/problem/POJ-1177 A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered by the oth…
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. Your friend Bill has to…
矩形面积并 线段树-扫描线裸题 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std; ; ; struct seg{ double x,y1,y2; int c; bool operator < (const seg a)const{ return x<a.x; } }s[maxm]; double y[maxm…
51nod 1206 Picture 矩形周长求并 | 线段树 扫描线 #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <iostream> using namespace std; typedef long long ll; #define INF 0x3f3f3f3f #define space putchar(' ') #…
传送门 •参考资料 [1]:算法总结:[线段树+扫描线]&矩形覆盖求面积/周长问题(HDU 1542/HDU 1828) •题意 给你 n 个矩形,求矩形并的周长: •题解1(两次扫描线) 周长可以分成两部分计算,横线和竖线: 如何求解横线的所有并的长度呢? 和求矩阵面积并的做法一样,先将 x 离散化: 每次更新的时候,记录一下上次更新后的横线总长度: ans += [现在这次总区间被覆盖的长度和上一次总区间被覆盖的长度之差的绝对值]; 求解竖线的所有并的长度何求解横线的长度相同: 需要注意的是…
看这篇博客前可以看一下扫描线求面积:线段树扫描线(一.Atlantis HDU - 1542(覆盖面积) 二.覆盖的面积 HDU - 1255(重叠两次的面积))  解法一·:两次扫描线 如图我们可以先用扫描线找出来横线的周长和,再用扫描线找纵线周长和 这里以横线来举例: 横线的长度 = [现在这次总区间被覆盖的程度和上一次总区间被覆盖的长度之差的绝对值] 下面有一点要注意的(参考链接:https://www.cnblogs.com/violet-acmer/p/11461660.html) 需…
线段树扫描线矩形周长并 #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #define MAXN 22222 using namespace std; int len[MAXN<<2]; bool lbd[MAXN<<2],rbd[MAXN<<2]; int numseg[MAXN<<2]; int cnt[…