poj1177】的更多相关文章

http://poj.org/problem?id=1177 (题目链接) 题意 求矩形周长并. Solution 转自:http://www.cnblogs.com/Booble/archive/2010/10/10/1847163.html 先看图: 为了解决这个问题 我们先把一坨一坨的矩形 进行矩形切割: 我们考虑周长由哪些部分构成 其中,红线是需要统计入周长的竖边,绿线是需要统计入周长的横边 我们称两条蓝线之间的部分为统计区间 我们需要依次统计从左到右的统计区间内的需要计数的矩形边,累加…
[POJ1177]Picture 试题描述 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…
题意:给定n个矩形,求他们的并的周长 n<=5e3,abs(x[i])<=1e4 思路:From https://www.cnblogs.com/kuangbin/archive/2013/04/10/3013437.html 真实“线段”树 #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream> #include&l…
题目链接: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…
//扫描线矩形周长的并 POJ1177 // 我是按x轴 #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cmath> #include <cstring> // #include <memory.h> // #include <bits/st…
题意:在平面直角坐标系内给出一些与坐标轴平行的矩形,将这些矩形覆盖的区域求并集,然后问这个区域的周长是多少.(边与边重合的地方不计入周长) 分析:线段树.曾经做过类似的求矩形覆盖的总面积的题.这道题同样要使用扫描线算法.属于线保留型线段树. 我们先领扫描线与y轴平行. 线段树内每个节点除了要记录该区间被覆盖了几层之外,还要记录当前状态下扫描线在该区间(开区间)内与多少条与x轴平行的边相交. 节点上还有两个bool型变量,记录该区间内(包括子树)线段覆盖是否接触到该区间的起始和结束点. 在父节点如…
求最终的覆盖图形周长,写这种代码应该短而精确,差的比较远 /* Problem: 1177 User: 96655 Memory: 348K Time: 32MS Language: C++ Result: Accepted */ #include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include <algorithm> using namespace…
思路: 以y的值进行离散化 根据x的值 对每一条y轴边进行处理,如果是"左边"则插入,是"右边"则删除. /* 扫描线+线段树+离散化 求多个矩形的周长 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> #include<queue> #include…
题目链接:http://poj.org/problem?id=1177 比矩形面积并麻烦点,需要更新竖边的条数(平行于x轴扫描)..求横边的时候,保存上一个结果,加上当前长度与上一个结果差的绝对值就行了... //STATUS:C++_AC_32MS_1416KB #include <functional> #include <algorithm> #include <iostream> //#include <ext/rope> #include <…
写了一发扫描线竟然狂WA不止,hdu死活过不了,poj和当时IOI的数据(还花了我1dsdn积分..)都过了. 然后看到谋篇blog里有评论,把数据拿下来发现WA了. 数据是 20 0 1 11 0 2 1就是有一条边贴着了,这个时候应该先加入新的边再删除,否则会算重. 另外,线段树不用清零哦. //#include<bits/stdc++.h> #include<cstdio> #include<cstring> #include<cstdlib> #in…