結果

問題 No.1420 国勢調査 (Easy)
ユーザー convexineqconvexineq
提出日時 2021-03-05 22:29:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 98,048 KB
最終ジャッジ日時 2024-04-16 10:14:24
合計ジャッジ時間 12,982 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,840 KB
testcase_01 WA -
testcase_02 AC 290 ms
87,808 KB
testcase_03 AC 278 ms
86,400 KB
testcase_04 AC 285 ms
86,400 KB
testcase_05 AC 277 ms
86,400 KB
testcase_06 AC 286 ms
87,808 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 176 ms
86,400 KB
testcase_14 WA -
testcase_15 AC 172 ms
86,360 KB
testcase_16 AC 178 ms
86,656 KB
testcase_17 AC 174 ms
86,016 KB
testcase_18 AC 172 ms
86,468 KB
testcase_19 AC 172 ms
86,500 KB
testcase_20 AC 172 ms
86,144 KB
testcase_21 AC 170 ms
86,476 KB
testcase_22 AC 382 ms
97,536 KB
testcase_23 AC 384 ms
97,408 KB
testcase_24 AC 380 ms
97,152 KB
testcase_25 AC 390 ms
97,408 KB
testcase_26 AC 395 ms
98,048 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    l,r = map(int,input().split())
    y = int(input())
    g[l-1].append((r-1,y))
    g[r-1].append((l-1,y))

res = [-1]*n
ok = 1
for i in range(n):
    if res[i] == -1:
        res[i] = 0
        st = [i]
        while st:
            v = st.pop()
            for c,d in g[v]:
                if res[c] == -1:
                    res[c] = d ^ res[v]
                    st.append(c)
                else:
                    if res[c] != d ^ res[v]:
                        ok = 0

if ok:
    print(*res,sep="\n")
else:
    print("No")
0