#include #include #include using namespace std; using i64 = int64_t; template struct SegTree { int N; vector dat; explicit SegTree(int n) { N = 1; while(N < n) { N <<= 1; } N <<= 1; dat.assign(N, 0); } void update(int a, int b, int k, int l, int r, int x) { if(k >= N) { return; } if(dat[k] != 0) { return; } if(b <= l || r <= a) { return; } update(a, b, 2*k+0, l, (l+r)/2, x); update(a, b, 2*k+1, (l+r)/2, r, x); if(a <= l && r <= b) { if(l+1 == r || (dat[2*k] == x && dat[2*k+1] == x)) { dat[k] = x; } } } void update(int a, int b, int x) { update(a, b, 1, 0, N/2, x); } void dump() { for(int i=0; i v(4); for(int i=N/2; i tree(N); for(int i=0; i