题目链接 Description 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 others. The length of the b…
题目链接 题意:给出n个矩形,每个矩形给左下 和 右上的坐标,求围成的周长的长度. 分析: 首先感谢大神的博客,最近做题经常看大神的博客:http://www.cnblogs.com/kuangbin/ 沿x轴离散化.和之前的矩阵面积并有点像. 但是一定要去重,否则会错 #include <iostream> #include <cstdio> #include <vector> #include <cstring> #include <cstdlib…
题目原网址:http://poj.org/problem?id=1177 题目中文翻译: 解题思路: 总体思路: 1.沿X轴离散化建树 2.按Y值从小到大排序平行与X轴的边,然后顺序处理 如果遇到矩形下面那条边则插入到线段树中,遇到矩形上面的边则将相应的边删除掉 根据线段树当前的状态统计长度 第二点是本题的核心思想,偶再举个例:   第一次求出的部分很好理解. 第二次求出的为什么会少了中间那部分.那是因为插入的新线段覆盖了第一条,此时线段树返回的长度是新的那一条的长度,将这个值再减去上次的就少了…
传送门 •参考资料 [1]:算法总结:[线段树+扫描线]&矩形覆盖求面积/周长问题(HDU 1542/HDU 1828) •题意 给你 n 个矩形,求矩形并的周长: •题解1(两次扫描线) 周长可以分成两部分计算,横线和竖线: 如何求解横线的所有并的长度呢? 和求矩阵面积并的做法一样,先将 x 离散化: 每次更新的时候,记录一下上次更新后的横线总长度: ans += [现在这次总区间被覆盖的长度和上一次总区间被覆盖的长度之差的绝对值]; 求解竖线的所有并的长度何求解横线的长度相同: 需要注意的是…
题意:给n个矩形,求矩形周长并 解法:跟求矩形面积并差不多,不过线段树节点记录的为: len: 此区间线段长度 cover: 此区间是否被整个覆盖 lmark,rmark: 此区间左右端点是否被覆盖 num: 此区间分离开的线段的条数 重点在转移的地方,不难理解. 代码: #include <iostream> #include <cmath> #include <iostream> #include <cstdio> #include <cstrin…
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 others. The length of the boundary of the un…
Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11777    Accepted Submission(s): 4983 Problem Description There are several ancient Greek texts that contain descriptions of the fabled…
  描述 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 others. The length of the boundary of t…
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…
看这篇博客前可以看一下扫描线求面积:线段树扫描线(一.Atlantis HDU - 1542(覆盖面积) 二.覆盖的面积 HDU - 1255(重叠两次的面积))  解法一·:两次扫描线 如图我们可以先用扫描线找出来横线的周长和,再用扫描线找纵线周长和 这里以横线来举例: 横线的长度 = [现在这次总区间被覆盖的程度和上一次总区间被覆盖的长度之差的绝对值] 下面有一点要注意的(参考链接:https://www.cnblogs.com/violet-acmer/p/11461660.html) 需…