Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#define MAXN 1000001using namespace std;struct Node{int L,R,V;};Node Tree[MAXN<<2];void Build(int id,int L,int R){Tree[id].L=L;Tree[id].R=R;Tree[id].V=0;if(L==R) return;int M=(L+R)>>1;Build(id<<1,L,M);Build(id<<1|1,M+1,R);}void Update(int id,int pos,int W){int L=Tree[id].L,R=Tree[id].R;if(L==R){Tree[id].V=W;return;}int M=(L+R)>>1;if(pos<=M) Update(id<<1,pos,W);else Update(id<<1|1,pos,W);Tree[id].V=min(Tree[id<<1].V,Tree[id<<1|1].V);}int Query(int id,int Left,int Right){int L=Tree[id].L,R=Tree[id].R;