poj1177Picture(线段树-周长并)】的更多相关文章

链接 神奇的扫描线啊 估计之前刷面积并的时候太急了 没来得及理解 .. 有一大段代码是与面积并一模一样的 都是离散化 更新 面积并是扫描的x  这次也一样 因为周长只算外围的 所以扫描到一条x边时 要减去上一次扫描到的 对于Y方向上 就是与面积并不大一样的地方了 看篇带图的讲解吧 网上的题解都大同小异 估计出自一人之手 http://blog.sina.com.cn/s/blog_691ce2b7010177dz.html 它是扫描的Y  其实方法是一样的 横过来就是 对于我的代码 自己感觉不好…
题目链接:http://poj.org/problem?id=1177 题意:给你n个矩形问你重叠后外边缘总共多长. 周长并与面积并很像只不过是处理的时候是   增加的周长=abs(上一次的线段的长度-更新后线段的长度) 然后分别处理一下竖着的边和横着的边就好了即建两次树就好. 就是一道典型的周长并问题,可以拿来练练周长并的写法. #include <iostream> #include <cstring> #include <algorithm> #include &…
  描述 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…
题意:给n个矩形,求矩形周长并 解法:跟求矩形面积并差不多,不过线段树节点记录的为: len: 此区间线段长度 cover: 此区间是否被整个覆盖 lmark,rmark: 此区间左右端点是否被覆盖 num: 此区间分离开的线段的条数 重点在转移的地方,不难理解. 代码: #include <iostream> #include <cmath> #include <iostream> #include <cstdio> #include <cstrin…
做这道题之前,建议先做POJ 1151  Atlantis,经典的扫描线求矩阵的面积并 参考连接: http://www.cnblogs.com/scau20110726/archive/2013/04/13/3018702.html 线段树辅助——扫描线法计算矩形周长并(轮廓线):http://www.cnblogs.com/scau20110726/archive/2013/04/13/3018687.htmlhttp://blog.csdn.net/ophunter/article/det…
Picture Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3897    Accepted Submission(s): 1978 Problem Description A number of rectangular posters, photographs and other pictures of the same shape…
线段树扫描线矩形周长并 #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[…
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(' ') #…
题目链接:http://poj.org/problem?id=1177 题目大意:若干个矩形,求这些矩形重叠形成的图形的轮廓周长. 解题思路:这里引用一下大牛的思路:kuangbin 总体思路: 1.沿X轴离散化建树 2.按Y值从小到大排序平行与X轴的边,然后顺序处理 如果遇到矩形下面那条边则插入到线段树中,遇到矩形上面的边则将相应的边删除掉 根据线段树当前的状态统计长度 第二点是本题的核心思想,偶再举个例: 第一次求出的部分很好理解. 第二次求出的为什么会少了中间那部分.那是因为插入的新线段覆…
Code: #include<bits/stdc++.h> #define maxn 200007 #define inf 100005 using namespace std; void setIO(string s) { string in=s+".in"; freopen(in.c_str(),"r",stdin); } struct Edge { int l,r,h,flag; }edges[maxn]; int n; namespace tr…