单点更新,区间最值
HDU 1754
//// Created by helica on 2018/3/18.////zkw线段树 单点修改 区间求最值//HDU 1754#include#include #include #include using namespace std;const int N = 200000 + 10;int M = 1;int T[N<<2];void change(int x, int v){ T[M+x] = v; for(int p= (M+x)>>1;p;p>>=1) T[p] = max(T[p<<1], T[p<<1|1]);}int query(int s, int t){ int ans = -1; for (s=M+s-1,t=M+t+1; s^t^1; s>>=1, t>>=1) { if (~s&1) ans = max(ans, T[s^1]); if ( t&1) ans = max(ans, T[t^1]); } return ans;}int main(){ int n,q,op,s,t; while(~scanf("%d %d", &n, &q)){ memset(T, 0, sizeof T); for(M=1;M <<=1); for (int i=0,tmp;i