結果

問題 No.1420 国勢調査 (Easy)
ユーザー c-yanc-yan
提出日時 2021-03-06 10:20:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-16 22:41:01
合計ジャッジ時間 5,843 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 34 ms
10,752 KB
testcase_08 AC 32 ms
10,752 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 34 ms
10,624 KB
testcase_11 AC 32 ms
10,752 KB
testcase_12 AC 38 ms
11,008 KB
testcase_13 WA -
testcase_14 AC 34 ms
10,880 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 43 ms
11,264 KB
testcase_28 AC 39 ms
11,008 KB
testcase_29 AC 45 ms
11,136 KB
testcase_30 AC 50 ms
11,520 KB
testcase_31 AC 49 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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