上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 16 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1698线段树,成段更新只查询全部的和sum[1],没写query 1 #include <stdio.h> 2 3 #define lson l, m, root<<1 4 #define rson m+1, r, root<<1|1 5 #define N 100100 6 7 int sum[N<<2], color[N<<2]; 8 9 void push_up(int root)10 {11 sum[root] = sum[root<& 阅读全文
posted @ 2013-02-18 14:24 Yuan1991 阅读(159) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2828线段树,单点更新反向添加,每次放到第a[i]个空位上,用线段树维护区间内空位数,单点查询,查询第x个空位的下标; 1 #include <stdio.h> 2 3 #define lson l, m, root<<1 4 #define rson m+1, r, root<<1|1 5 6 const int maxn = 200010; 7 int sum[maxn<<2]; 8 9 void push_up(int root)10 {11 sum[root] = sum[root&l 阅读全文
posted @ 2013-02-02 20:00 Yuan1991 阅读(119) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2795线段树,单点更新好题,查询属于全区间的单点查询,目标值:准备贴的海报宽度如果左子树的最大值比目标值大,则优先查且只查左子树(我们想要得到编号最小且满足条件的行贴海报)否则查右子树,如果左右子树的最大值,都比目标值小,就返回-1(没地方贴了~)WA了一次,没考虑高度为1的展板。 1 #include <stdio.h> 2 3 #define lson l, m, root<<1 4 #define rson m+1, r, root<<1|1 5 6 const in 阅读全文
posted @ 2013-02-02 15:36 Yuan1991 阅读(168) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1394线段树,单点更新用线段树优化,求逆序数,O(N*logN) 1 #include <stdio.h> 2 3 #define lson l, m, root<<1 4 #define rson m+1, r, root<<1|1 5 6 const int maxn = 5010; 7 int sum[maxn<<2]; 8 9 void push_up(int root)10 {11 sum[root] = sum[root<<1] + su 阅读全文
posted @ 2013-02-02 12:48 Yuan1991 阅读(112) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1754线段树,单点更新 1 #include <stdio.h> 2 3 #define lson l, m, root<<1 4 #define rson m+1, r, root<<1|1 5 6 const int maxn = 200010; 7 const int minint = 1<<31; 8 int max1[maxn<<2]; 9 10 int max(int x, int y)11 {12 return x>y? x: y 阅读全文
posted @ 2013-02-01 23:07 Yuan1991 阅读(136) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 16 下一页