poj 3277 Mountains】的更多相关文章

http://poj.org/problem?id=3227 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #define maxn 2000 using namespace std; int n,h; ; int cmp(double x) { ; ) ; ; } struct point { double x,y; point() {} point(d…
POJ 3277 City Horizon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18466 Accepted: 5077 Description Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city horizon and observe the beautiful silho…
学习博客推荐——线段树+扫描线(有关扫描线的理解) 我觉得要注意的几点 1 我的模板线段树的叶子节点存的都是 x[L]~x[L+1] 2 如果没有必要这个lazy 标志是可以不下传的 也就省了一个push_down 3 注意push_up 写法有点不一样,不过是可以改成一样的. 简单裸题*2 L - Atlantis  HDU - 1542 #include <iostream> #include <cstdio> #include <algorithm> #inclu…
题目链接 题意: 给一些矩形,给出长和高,其中长是用区间的形式给出的,有些区间有重叠,最后求所有矩形的面积. 分析: 给的区间的范围很大,所以需要离散化,还需要把y坐标去重,不过我试了一下不去重 也不会出错, 所有的区间都能列出来,只是在查找的时候费点事. 给的矩形相当于在同一水平线上的,也就是y1坐标相当于为0,其他的就和 poj 1151 Atlantis 差不多了. 我写的思路是按照矩形面积并的思路写的: 但是还有另一种方法也是挺简单的,就是把给的矩形按照高从小到大排序,然后依次插入线段树…
题意: 思路: 线段树求矩形面积的并...同 POJ 1151 //By SiriusRen #include <cstdio> #include <algorithm> using namespace std; #define N 88888 int n,u,tot,xx,yy,h[N]; long long ans; struct Node{int x,h,cover;}node[4*N]; struct Tree{int l,r,cover,len;}tree[4*N]; b…
题目链接 类似求面积并..2Y.. #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namespace std; #define LL __int64 #define maxn 40100 #define lson l , m, rt<<1 #define rson m+1, r,rt&…
来自这两篇博客的总结 http://blog.csdn.net/SunnyYoona/article/details/43938355 http://m.blog.csdn.net/blog/mr_zys/10226425 题目大意 如图所示,在一条水平线上有N个建筑物,建筑物都是长方形的,且可以互相遮盖.给出每个建筑物的左右坐标值Ai,Bi以及每个建筑物的高Hi,需要计算出这些建筑物总共覆盖的面积. 题目数据范围: 建筑物个数N:1 <= N <= 40000 建筑物左右坐标值Ai, Bi:…
网上还有用unique函数和lowerbound函数离散的方法,可以百度搜下题解就有. 这里给出介绍unique函数的链接:http://www.cnblogs.com/zhangshu/archive/2011/07/23/2115090.html #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <set> /* 题…
标题效果: 每间房子的长度给出阴影(在间隔代表)而高度,求阴影总面积. 解题思路:矩形面积并. 以下是代码: #include <set> #include <map> #include <queue> //#include <math.h> #include <vector> #include <string> #include <stdio.h> #include <string.h> #include &…
OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 3094) 初期: 一.基本算法: 枚举. (POJ 1753,POJ 2965) 贪心(POJ 1328,POJ 2109,POJ 2586) 递归和分治法. 递推. 构造法.(POJ 3295) 模拟法.(POJ 1068,POJ 2632,POJ 1573,POJ 2993,POJ 2996) 二…