随笔分类 - 线段树
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
阅读全文
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
阅读全文
浙公网安备 33010602011771号