結果
問題 | No.1420 国勢調査 (Easy) |
ユーザー |
👑 ![]() |
提出日時 | 2022-02-17 02:06:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 394 ms / 2,000 ms |
コード長 | 511 bytes |
コンパイル時間 | 144 ms |
コンパイル使用メモリ | 82,100 KB |
実行使用メモリ | 99,964 KB |
最終ジャッジ日時 | 2024-06-29 07:25:25 |
合計ジャッジ時間 | 11,545 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
N,M=map(int,input().split())G=[[(0,0) for j in range(0)] for i in range(N)]for i in range(M):A,B=map(int,input().split())A-=1B-=1Y=int(input())G[A].append((B,Y))G[B].append((A,Y))ans=[-1]*Nfor i in range(N):if ans[i]!=-1:continueans[i]=0order=[i]*1ind=0while ind!=len(order):a=order[ind]for x in G[a]:if ans[x[0]]==-1:ans[x[0]]=(ans[a]^x[1])order.append(x[0])elif ans[x[0]]!=(ans[a]^x[1]):print(-1)exit()ind+=1for i in range(N):print(ans[i])