結果

問題 No.1641 Tree Xor Query
ユーザー raven7959raven7959
提出日時 2021-08-17 16:47:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 604 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,012 KB
実行使用メモリ 205,824 KB
最終ジャッジ日時 2024-04-18 21:47:19
合計ジャッジ時間 4,123 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,736 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 36 ms
52,096 KB
testcase_03 AC 37 ms
52,352 KB
testcase_04 AC 40 ms
52,992 KB
testcase_05 AC 41 ms
53,376 KB
testcase_06 AC 40 ms
53,632 KB
testcase_07 AC 39 ms
53,248 KB
testcase_08 AC 38 ms
52,096 KB
testcase_09 AC 38 ms
52,864 KB
testcase_10 AC 39 ms
52,736 KB
testcase_11 AC 37 ms
52,096 KB
testcase_12 AC 38 ms
52,352 KB
testcase_13 AC 590 ms
205,696 KB
testcase_14 AC 604 ms
205,824 KB
testcase_15 AC 106 ms
77,116 KB
testcase_16 AC 150 ms
78,776 KB
testcase_17 AC 142 ms
78,268 KB
testcase_18 AC 123 ms
79,300 KB
testcase_19 AC 109 ms
76,928 KB
testcase_20 AC 351 ms
94,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
0