摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1698View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 using namespace std; 5 #define max 100000 6 int s[max*4],te[max*4]; 7 void pushup(int w) 8 { 9 s[w] = s[2*w]+s[2*w+1];10 }11 void pushdown(int w,int m)12 {13 if(t 阅读全文
posted @ 2012-08-09 23:40 _雨 阅读(171) 评论(0) 推荐(0) 编辑
摘要: http://acm.sdut.edu.cn/bbs/read.php?tid=5651。。本来只会向上更新 现在学习了如何向下更新 延迟标记法。。。使复杂度降低View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 using namespace std; 5 #define max 100000 6 __int64 s[max*4],te[max*4]; 7 void pushup(int w) 8 { 9 s[w] = s[2*w]+s[2*w+1];10 }1 阅读全文
posted @ 2012-08-09 23:09 _雨 阅读(155) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1754依次比较左右子节点 父节点存最大值View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #define MAX 200000 5 using namespace std; 6 int s[MAX*4],a; 7 void push(int w) 8 { 9 if(s[2*w]>s[2*w+1])10 s[w] = s[2*w];11 else12 s[w... 阅读全文
posted @ 2012-08-09 11:55 _雨 阅读(170) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4217开一个数组标记这个数是否被拿走 s[w]为区间和 当求第K小的数的时候 让他与s[w]的左右子树比较 看在哪个区间中 依次找下去 总会找到一个s[]与他相等 所对应的区间就是那个应该被拿走的值View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #define MAX 262144 5 using namespace std; 6 int to[4*MAX]; 7 __int 阅读全文
posted @ 2012-08-09 10:20 _雨 阅读(192) 评论(0) 推荐(0) 编辑