随笔分类 -  线段树

HDU 1166 敌兵布阵【线段树】
摘要:线段树的基本操作,具体看代码注释。View Code #include <iostream>#include <string>using namespace std;const int MAX = 50005; struct Tree{ int left; int right; int num;}tr[MAX*3];int arr[MAX],n,t,a,b,ans;string cmd;void build(int l,int r,int now) // 构造线段树{ tr[now].left = l; tr[now].right = r; if(l == r) {tr 阅读全文
posted @ 2011-04-09 13:11 c++fans 阅读(307) 评论(0) 推荐(1)
HDU 1754 I Hate It【线段树】
摘要:没想到竟然能一次AC,而且只花了20分钟不到。第一道线段树的题了,纪念一下。 考察线段树的基本操作:建树,区间最值查询和更新操作.View Code #include <iostream>using namespace std;const int MAX = 200005;struct Tree{ int left; int right; int score;}tr[MAX*3];int n,m,s[MAX],a,b;char cmd;int max(int x,int y){ if(x > y) return x; else return y;}void build(int 阅读全文
posted @ 2011-04-08 23:49 c++fans 阅读(331) 评论(0) 推荐(0)