Effect: Given an undirected graph, point I $ $ $ B_i $ right point, edge $ (x, y, z) $ sequence is the contribution of $ A [b_x \ oplus b_y] $ plus $ z $.
A plurality of sets interrogation, a total of three operations: 1. Modify the right edge point 2. Modification 3. Right request sequence and $ A $ interval.
FIG degree by block.
Tap for direct contribution Fenwick tree maintenance complexity $ O (17 \ sqrt {m}) $
Each heavy side selected from a larger degree of focus of a built $ X $ $ 01trie $, asking $ [L, R] $ interval and is equivalent to divergent or $ b [x] $ in the range of $ [L, R & lt] $ and complexity $ O (17 \ sqrt {m}) $.
#include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #include <string> #include <string.h> #include <bitset> #define REP(i,a,n) for(int i=a;i<=n;++i) #define PER(i,a,n) for(int i=n;i>=a;--i) #define hr putchar(10) #define pb push_back #define lc (o<<1) #define rc (lc|1) #define mid ((l+r)>>1) #define ls lc,l,mid #define rs rc,mid+1,r #define x first #define y second #define io std::ios::sync_with_stdio(false) #define endl '\n' #define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;}) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int P = 998244353; const int N = 131080; const int S = 4000; int n, m, q, x[N], y[N], z[N]; int b[N], deg[N], ID[N], E[N]; vector<int> big, small[N]; struct { ll c[N]; void add(int x, int v) { for (++x; x<N; x+=x&-x) c[x]+=v; } ll qry(int x) { ll ret = 0; for (++x; x; x^=x&-x) ret+=c[x]; return ret; } } BIT; struct { int T, tot; struct {int ch[2],v;} a[N<<2]; void add(int &o, int d, int x, int v) { if (!o) o = ++tot; a[o].v = (a[o].v+v)%P; if (d>=0) add(a[o].ch[x>>d&1],d-1,x,v); } void add(int x, int v) { add(T,16,x,v); } ll qry(int o, int d, int x, int v) { if (d<0) return a[o].v; int f1 = x>>d&1, f2 = v>>d&1; if (f2) return a[a[o].ch[f1]].v+qry(a[o].ch[!f1],d-1,x,v); return qry(a[o].ch[f1],d-1,x,v); } ll qry(int x, int v) { ll ret = qry(T,16,x,v); return ret; } } tr[100]; void add(int id, int tp) { if (E[id]) tr[E[id]].add(b[x[id]]^b[y[id]]^b[big[E[id]]],tp*z[id]); else BIT.add(b[x[id]]^b[y[id]],tp*z[id]); } int qry(int x) { if (x<0) return 0; ll ans = BIT.qry(x); for (int i=1; i<big.size(); ++i) { ans += tr[i].qry(b[big[i]],x); } return ans%P; } int main() { scanf("%d%d%d", &n, &m, &q); REP(i,1,n) scanf("%d", b+i); REP(i,1,m) { scanf("%d%d%d", x+i, y+i, z+i); ++deg[x[i]],++deg[y[i]]; } big.pb(0); REP(i,1,n) if (deg[i]>=S) { ID[i] = ++*ID; big.pb(i); } REP(i,1,m) { if (ID[x[i]]&°[x[i]]>deg[y[i]]) { E[i] = ID[x[i]]; small[y[i]].pb(i); } else if (ID[y[i]]) { E[i] = ID[y[i]]; small[x[i]].pb(i); } else { small[x[i]].pb(i); small[y[i]].pb(i); } add(i, 1); } while (q--) { int op,x,y; scanf("%d%d%d", &op, &x, &y); if (op==1) { for (auto t:small[x]) add(t,-1); b[x] = y; for (auto t:small[x]) add(t,1); } else if (op==2) { add(x,-1); z[x] = y; add(x,1); } else { int ans = (qry(y)-qry(x-1))%P; if (ans<0) ans += P; printf("%d\n", ans); } } }