#line 1 "/workspaces/compro/lib/template.hpp" #line 1 "/workspaces/compro/lib/io/vector.hpp" #include #include #ifndef IO_VECTOR #define IO_VECTOR template std::ostream &operator<<(std::ostream &out, const std::vector &v) { int size = v.size(); for (int i = 0; i < size; i++) { std::cout << v[i]; if (i != size - 1) std::cout << " "; } return out; } template std::istream &operator>>(std::istream &in, std::vector &v) { for (auto &el : v) { std::cin >> el; } return in; } #endif #line 4 "/workspaces/compro/lib/template.hpp" #include #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define ALL(v) (v).begin(), (v).end() #define coutd(n) cout << fixed << setprecision(n) #define ll long long int #define vl vector #define vi vector #define MM << " " << using namespace std; template void chmin(T &a, T b) { if (a > b) a = b; } template void chmax(T &a, T b) { if (a < b) a = b; } // 重複を消す。計算量はO(NlogN) template void unique(std::vector &v) { std::sort(v.begin(), v.end()); v.erase(std::unique(v.begin(), v.end()), v.end()); } #line 2 "main.cpp" void solve(ll N, ll Q, const std::vector &C, const std::vector &a, const std::vector &b, const std::vector &T, const std::vector &x, const std::vector &y) { ll M = 2 * sqrt(N * Q); vector cost = C; vector dp(N, 0); vector> g(N); REP(i, N - 1) { g[a[i]].push_back(b[i]); g[b[i]].push_back(a[i]); } vector isLarge(N, false); vector parent(N); auto dfs = [&](int cur, int par, auto self) -> void { int s = 0; dp[cur] = cost[cur]; parent[cur] = par; for (const auto &el : g[cur]) { if (el == par) continue; self(el, cur, self); dp[cur] ^= dp[el]; s++; } if (s > M) isLarge[cur] = true; }; dfs(0, -1, dfs); REP(i, Q) { if (T[i] == 1) { cost[x[i]] ^= y[i]; dp[x[i]] ^= y[i]; int target = parent[i]; while (target != -1 && isLarge[target]) { cost[target] ^= y[i]; dp[target] ^= y[i]; target = parent[target]; } } else { if (isLarge[x[i]]) { cout << dp[x[i]] << endl; } else { int ans = cost[x[i]]; for (const auto &el : g[x[i]]) { if (el == parent[x[i]]) continue; ans ^= dp[el]; } cout << ans << endl; } } } } // generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator) int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; std::cin >> N; std::vector C(N); vl a(N - 1), b(N - 1); std::cin >> Q; std::vector T(Q), x(Q); vi y(Q); for (int i = 0; i < N; ++i) { std::cin >> C[i]; } for (int i = 0; i < N - 1; ++i) { std::cin >> a[i] >> b[i]; a[i]--; b[i]--; } for (int i = 0; i < Q; ++i) { std::cin >> T[i] >> x[i] >> y[i]; x[i]--; } solve(N, Q, C, a, b, T, x, y); return 0; }