| 线段树-地平线horizon】的更多相关文章

[题目描述]:在地平线上有n个建筑物.每个建筑物在地平线上可以看成一个下边界和地平线重合的矩形.每个建筑物有三个描述(Li ,Ri,Hi),分别表示该建筑物的左边界,右边界,高度.输出输出这些建筑物在地平线上投影的总面积. [输入文件] 输入文件horizon.in第一行包含一个整数n,表示有n个建筑物. 以下下n.行,每行三个整数Li ,Ri,Hi. [输出文件] 输出这些建筑物在地平线上投影的总面积 [样例] horizon.in   horizon.out   4 2 5 1 9 10 4…
[BZOJ1645][Usaco2007 Open]City Horizon 城市地平线 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 silhouettes formed by the rectangular buildings. The entire ho…
http://www.lydsy.com/JudgeOnline/problem.php?id=1645 这题的方法很奇妙啊...一开始我打了一个“离散”后的线段树.............果然爆了..(因为压根没离散) 这题我们可以画图知道,每2个点都有一个区间,而这个区间的高度是一样的,因此,我们只需要找相邻的两个点,用他们的距离×这个区间的高度就是这块矩形的面积. 将所有这样的矩形累计起来就是答案了. 因此线段树就离散到了O(n)的大小..真神.. 只需要维护点的位置,然后维护区间最值即可…
bzoj题面什么鬼啊-- 题目大意:有一个初始值均为0的数列,n次操作,每次将数列(ai,bi-1)这个区间中的数与ci取max,问n次后元素和 离散化,然后建立线段树,每次修改在区间上打max标记即可 #include<iostream> #include<cstdio> #include<map> #include<algorithm> using namespace std; const int N=100005; int n,g[N],tot,a[N…
链接 题意:N个矩形块,交求面积并. 题解 显然对于每个 \(x\),只要求出这个 \(x\) 上面最高的矩形的高度,即最大值 将矩形宽度离散化一下,高度从小到大排序,线段树区间set,然后求和即可 注意它给的矩形区间是 \([L,R)\) 这样在线段树里直接维护 \([L,R)\) 这样的区间即可 #include<bits/stdc++.h> #define REP(i,a,b) for(int i(a);i<=(b);++i) using namespace std; typede…
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…
http://poj.org/problem?id=3277 City Horizon Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15255   Accepted: 4111 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 o…
学习博客推荐——线段树+扫描线(有关扫描线的理解) 我觉得要注意的几点 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…
来自这两篇博客的总结 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> /* 题…