摘要: 线段树View Code 1 /* 2 poj3468 3 */ 4 #include <iostream> 5 using namespace std; 6 const int N = 100005; 7 8 struct node 9 { 10 int left, right; 11 long long num, add; 12 }tree[4*N]; 13 14 int L(int n) 15 { 16 return n<<1; 17 } 18 int R (int n) 19 { 20 return (n<<1) | 1... 阅读全文
posted @ 2013-04-24 18:51 旅行的蜗牛 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 线段树资料:http://dongxicheng.org/structure/segment-tree/PS: 以HDU1166为例线段树的使用一般分如下几个操作建树插入查询建树 建树的操作类似与构建一个二叉树,是一个递归的过程void build(int l, int r, int step) { tree[step].left = l; tree[step].right = r; tree[step].add = 0; if (l == r) //到达叶子节点了 { tree[step].num = a[l]; ... 阅读全文
posted @ 2013-04-24 10:07 旅行的蜗牛 阅读(243) 评论(0) 推荐(0) 编辑