摘要:poj1389:http://poj.org/problem?id=1389题意:求矩形面积的并题解:扫描线加线段树 同poj1389 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn=2002; 7 int num; 8 struct Node{ 9 int l;10 int r;11 int tp;12 int y;13 bool operator =r)update(l,r,f,idx1){57 mid=(...
阅读全文
摘要:poj1151:http://poj.org/problem?id=1151题意:求矩形面积的并题解:扫描线加线段树 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn=202;//注意这里的初始化,不能开小了,是200条边 7 int num;//记录x坐标的个数 8 struct Node{ 9 double l;//边的左端点 10 double r;//边的又端点 11 int tp;//是出度边还是入度边 12 double y;/...
阅读全文
摘要:poj2823:http://poj.org/problem?id=2823题意:给出一个序列,要求得到所有长度为k的连续子序列的最大和最小值。题解:直接上线段树 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn=1000002; 7 int n,k,s; 8 struct Node{ 9 int left;10 int right;11 int minn;12 int maxn;13 }node[4*maxn];14 void build(...
阅读全文
摘要:hdu1166:http://acm.hdu.edu.cn/showproblem.php?pid=1166题意:n个阵营一字排开,每个初始有a[i]个人。现有两种操作:Q a b 查询[a,b]之间总人数并输出A/S a b 在a号位添加/删除b个人题解:用线段树维护,就是单点更新,区间查询。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int n,a,b; 7 struct Node{ 8 int left;//左二子 9 int right;//右儿子 10 int ...
阅读全文