Code: #include<cstdio> #include<algorithm> #include<string> #define maxn 1030000 #define inf 300000 #define ll long long using namespace std; void setIO(string s) { string in=s+".in"; freopen(in.c_str(),"r",stdin); }…
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…
1645: [Usaco2007 Open]City Horizon 城市地平线 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 315  Solved: 157[Submit][Status] 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 t…
http://www.lydsy.com/JudgeOnline/problem.php?id=1645 这题的方法很奇妙啊...一开始我打了一个“离散”后的线段树.............果然爆了..(因为压根没离散) 这题我们可以画图知道,每2个点都有一个区间,而这个区间的高度是一样的,因此,我们只需要找相邻的两个点,用他们的距离×这个区间的高度就是这块矩形的面积. 将所有这样的矩形累计起来就是答案了. 因此线段树就离散到了O(n)的大小..真神.. 只需要维护点的位置,然后维护区间最值即可…
BZOJ_1654_[Usaco2007 Open]City Horizon 城市地平线_扫描线 Description N个矩形块,交求面积并. Input * Line 1: A single integer: N * Lines 2..N+1: Input line i+1 describes building i with three space-separated integers: A_i, B_i, and H_i Output * Line 1: The total area,…
[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…
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 horizon is represented by a number line with N…
http://www.lydsy.com/JudgeOnline/problem.php?id=1628 http://www.lydsy.com/JudgeOnline/problem.php?id=1683 又是重复的题.... 单调栈维护递减,然后相同的话矩形-1 #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream&g…
来自这两篇博客的总结 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:…