結果

問題 No.2277 Honest or Dishonest ?
ユーザー ニックネームニックネーム
提出日時 2023-04-21 21:57:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 711 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 40,576 KB
最終ジャッジ日時 2024-04-25 18:57:29
合計ジャッジ時間 23,313 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 27 ms
10,752 KB
testcase_03 AC 578 ms
34,432 KB
testcase_04 AC 566 ms
35,968 KB
testcase_05 AC 223 ms
22,656 KB
testcase_06 AC 484 ms
30,336 KB
testcase_07 AC 393 ms
27,136 KB
testcase_08 AC 205 ms
22,016 KB
testcase_09 AC 343 ms
27,776 KB
testcase_10 AC 295 ms
22,656 KB
testcase_11 AC 138 ms
16,640 KB
testcase_12 AC 277 ms
21,760 KB
testcase_13 AC 544 ms
32,896 KB
testcase_14 AC 368 ms
24,448 KB
testcase_15 AC 194 ms
20,736 KB
testcase_16 AC 374 ms
26,752 KB
testcase_17 AC 187 ms
18,560 KB
testcase_18 AC 523 ms
34,560 KB
testcase_19 AC 542 ms
34,944 KB
testcase_20 AC 425 ms
29,696 KB
testcase_21 AC 381 ms
26,752 KB
testcase_22 AC 362 ms
26,880 KB
testcase_23 AC 539 ms
32,256 KB
testcase_24 AC 325 ms
25,600 KB
testcase_25 AC 407 ms
30,208 KB
testcase_26 AC 142 ms
19,712 KB
testcase_27 AC 272 ms
21,504 KB
testcase_28 AC 203 ms
20,736 KB
testcase_29 AC 289 ms
25,344 KB
testcase_30 AC 233 ms
21,120 KB
testcase_31 AC 422 ms
28,544 KB
testcase_32 AC 258 ms
24,064 KB
testcase_33 AC 528 ms
34,176 KB
testcase_34 AC 592 ms
35,712 KB
testcase_35 AC 93 ms
16,128 KB
testcase_36 AC 359 ms
26,368 KB
testcase_37 AC 569 ms
33,408 KB
testcase_38 AC 137 ms
15,872 KB
testcase_39 AC 184 ms
18,176 KB
testcase_40 AC 91 ms
15,360 KB
testcase_41 AC 595 ms
36,992 KB
testcase_42 AC 430 ms
29,312 KB
testcase_43 AC 656 ms
40,576 KB
testcase_44 AC 672 ms
40,448 KB
testcase_45 AC 689 ms
40,448 KB
testcase_46 AC 677 ms
40,576 KB
testcase_47 AC 647 ms
40,448 KB
testcase_48 AC 665 ms
40,576 KB
testcase_49 AC 711 ms
40,448 KB
testcase_50 AC 653 ms
40,448 KB
testcase_51 AC 697 ms
40,448 KB
testcase_52 AC 681 ms
40,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,q = map(int,input().split())
adj = [[] for _ in range(n)]; mod = 998244353
for _ in range(q):
    a,b,c = map(int,input().split())
    adj[a-1].append((b-1,c)); adj[b-1].append((a-1,c))
ans = 1; f = [-1]*n
for i in range(n):
    if f[i]!=-1: continue
    ans = ans*2%mod; f[i] = 0; st = [i]
    while st:
        p = st.pop()
        for v,c in adj[p]:
            if f[v]==-1: f[v] = f[p]^c; st.append(v)
            elif f[v]!=f[p]^c: ans = 0
print(ans)
0