結果
| 問題 | No.1641 Tree Xor Query |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-17 16:47:40 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 405 ms / 5,000 ms |
| コード長 | 597 bytes |
| 記録 | |
| コンパイル時間 | 526 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 213,888 KB |
| 最終ジャッジ日時 | 2026-04-26 17:27:51 |
| 合計ジャッジ時間 | 3,856 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
import sys
sys.setrecursionlimit(10**9)
N,Q=map(int,input().split())
C=list(map(int,input().split()))
G=[[] for _ in range(N)]
for i in range(N-1):
a,b=map(lambda x:int(x)-1,input().split())
G[a].append(b)
G[b].append(a)
seen=[False]*N
par=[-1]*N
subtree_xor=C
def dfs(G,v,p=-1):
seen[v]=True
par[v]=p
for nextv in G[v]:
if nextv!=p:
dfs(G,nextv,v)
for c in G[v]:
if c!=p:
subtree_xor[v]^=subtree_xor[c]
dfs(G,0)
for _ in range(Q):
t,x,y=map(int,input().split())
x-=1
if t==1:
while x!=-1:
subtree_xor[x]^=y
x=par[x]
else:
print(C[x])