結果
| 問題 | No.1420 国勢調査 (Easy) | 
| コンテスト | |
| ユーザー |  c-yan | 
| 提出日時 | 2021-03-06 10:20:38 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 407 bytes | 
| コンパイル時間 | 453 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 11,392 KB | 
| 最終ジャッジ日時 | 2024-10-08 04:40:46 | 
| 合計ジャッジ時間 | 5,228 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 12 WA * 18 | 
ソースコード
N, M = map(int, input().split())
d = {}
for _ in range(M):
    A, B = map(int, input().split())
    Y = int(input())
    if A not in d and B not in d:
        d[A] = 0
    if A not in d:
        d[A] = d[B] ^ Y
    if B not in d:
        d[B] = d[A] ^ Y
    if d[A] ^ d[B] != Y:
        print(-1)
        exit()
for i in range(1, N + 1):
    if i not in d:
        print(0)
    else:
        print(d[i])
            
            
            
        