甚至DFS也能过吧 Mayor's posters POJ - 2528 The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to bui…
Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 74745   Accepted: 21574 Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral post…
//线段树区间覆盖 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; ; int flag; struct node{ int l,r; //vis 是这块区域是否完全被覆盖 bool vis; }tr[N<<]; struct point { int id; int x; }post[N<<];…
题意:输入t组数据,输入n代表有n块广告牌,按照顺序贴上去,输入左边和右边到达的地方,问贴完以后还有多少块广告牌可以看到(因为有的被完全覆盖了). 思路:很明显就是线段树更改区间,不过这个区间的跨度有点大(看数据),不过n<10000,所以就可以把这些广告牌的边界重新定义编号,比如: n输入 2 1 6 2 13 排序以后,1还是1,2还是2,6就可以看成3,13就可以看成4 变成: 1 3 2 4 其实性质还是没有变,两个广告牌都可以看到,不过线段树开的数组就不用很大了. #include<…
链接: http://poj.org/problem?id=2528 覆盖问题, 要从后往前找, 如果已经被覆盖就不能再覆盖了,否则就可以覆盖 递归呀递归什么时候我才能吃透你 代码: #include<stdio.h> #include<algorithm> #include<stdlib.h> #include<string.h> using namespace std; #define Lson r<<1 #define Rson r<…
题意 贴海报 最后可以看到多少海报 思路 :离散化大区间  其中[1,4] [5,6]不能离散化成[1,2] [2,3]因为这样破坏了他们的非相邻关系 每次离散化区间 [x,y]时  把y+1点也加入就行了 注:参考了上海全能王csl的博客! #include<cstdio> #include<algorithm> #include<set> #include<vector> #include<cstring> #include<iostr…
The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to build an electoral wall for placing the…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 59798   Accepted: 18237 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of…
题目传送门 /* 线段树-成段更新:裸题,成段增减,区间求和 注意:开long long:) */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r,…
扫描线算是线段树的一个比较特殊的用法,虽然NOIP不一定会考,但是学学还是有用的,况且也不是很难理解. 以前学过一点,不是很透,今天算是搞懂了. 就以这道题为例吧:嘟嘟嘟 题目的意思是在一个二维坐标系中给了很多矩形,然后求这些矩形的总覆盖面积,也就是面积并. 我就不讲暴力,直接切入正题吧. 扫描线,听这个名字就可以想象一下,现在有这么多重叠的矩形,然后有一个线从下往上扫,那么每一时刻这条线上被覆盖的长度之和,就是我们要求的答案. 那么首先可以想到,要把给定的矩形都离线下来,拆成上下来个面,并标记…