#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; ll cnt=0; vector in, out; vector tour, C; //in...頂点xに入ったのは何ステップ目か? //out...頂点xから出たのは何ステップ目か? //tour...i番目に訪れた頂点のxor(帰りは0) void euler_tour(vector> &E, ll from, ll p){ tour.push_back(C[from]); in[from] = cnt; cnt++; for(auto to : E[from]){ if (p == to) continue; euler_tour(E, to, from); } out[from] = cnt; tour.push_back(0); cnt++; } templatestruct SegTree { vector seg; long long N = 1; SegTree (long long n) : SegTree(vector(n, e())) {} SegTree (const vector &v){ long long n = v.size(); while (N < n) N *= 2; seg.resize(N*2-1, e()); for (long long i=0; i=0; i--){ seg[i] = op(seg[i*2+1], seg[i*2+2]); } } void set(long long loc, S val){ loc += N-1; seg[loc] = val; while (loc != 0){ loc = (loc-1)/2; seg[loc] = op(seg[loc*2+1], seg[loc*2+2]); } } //op(a[l], ..., a[r]) S prod (long long l, long long r) const{ return _prod(l, r, 0, 0, N-1); } S all_prod() const{ return seg[0]; } S _prod (long long l, long long r, long long idx, long long bitl, long long bitr) const{ if (r < bitl || l > bitr) return e(); if (l <= bitl && bitr <= r) return seg[idx]; long long bitm = (bitl+bitr)/2; return op(_prod(l, r, idx*2+1, bitl, bitm), _prod(l, r, idx*2+2, bitm+1, bitr)); } S get (long long i) const{ return seg[i+N-1]; } void show() const{ for (int i=N-1; i> N >> Q; C.resize(N); for (int i=0; i> C[i]; vector> E(N); for (int i=0; i> a >> b; a--; b--; E[a].push_back(b); E[b].push_back(a); } in.resize(N); out.resize(N); euler_tour(E, 0, -1); /* for (int i=0; i tree(tour); while(Q){ Q--; cin >> t >> a >> b; a--; if (t == 1) tree.set(in[a], tree.get(in[a]) ^ b); else cout << tree.prod(in[a], out[a]) << endl; } return 0; }