結果

問題 No.2277 Honest or Dishonest ?
ユーザー ああいいああいい
提出日時 2023-04-21 23:40:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 93,240 KB
最終ジャッジ日時 2024-04-25 19:10:16
合計ジャッジ時間 10,461 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,464 KB
testcase_01 AC 32 ms
53,436 KB
testcase_02 AC 32 ms
52,584 KB
testcase_03 AC 209 ms
88,060 KB
testcase_04 AC 226 ms
90,800 KB
testcase_05 AC 129 ms
84,100 KB
testcase_06 AC 173 ms
85,908 KB
testcase_07 AC 139 ms
84,544 KB
testcase_08 AC 114 ms
83,900 KB
testcase_09 AC 164 ms
86,424 KB
testcase_10 AC 129 ms
81,272 KB
testcase_11 AC 94 ms
77,868 KB
testcase_12 AC 107 ms
79,372 KB
testcase_13 AC 181 ms
87,512 KB
testcase_14 AC 120 ms
81,568 KB
testcase_15 AC 117 ms
83,356 KB
testcase_16 AC 147 ms
84,344 KB
testcase_17 AC 111 ms
80,356 KB
testcase_18 AC 196 ms
89,740 KB
testcase_19 AC 193 ms
89,904 KB
testcase_20 AC 167 ms
86,048 KB
testcase_21 AC 147 ms
83,380 KB
testcase_22 AC 153 ms
85,348 KB
testcase_23 AC 176 ms
85,660 KB
testcase_24 AC 142 ms
84,984 KB
testcase_25 AC 166 ms
88,116 KB
testcase_26 AC 98 ms
81,780 KB
testcase_27 AC 109 ms
80,112 KB
testcase_28 AC 116 ms
83,180 KB
testcase_29 AC 130 ms
84,768 KB
testcase_30 AC 115 ms
81,200 KB
testcase_31 AC 139 ms
85,108 KB
testcase_32 AC 133 ms
84,736 KB
testcase_33 AC 192 ms
89,580 KB
testcase_34 AC 188 ms
88,980 KB
testcase_35 AC 91 ms
79,920 KB
testcase_36 AC 145 ms
84,328 KB
testcase_37 AC 174 ms
86,124 KB
testcase_38 AC 84 ms
77,056 KB
testcase_39 AC 98 ms
80,080 KB
testcase_40 AC 90 ms
79,172 KB
testcase_41 AC 185 ms
89,368 KB
testcase_42 AC 144 ms
85,692 KB
testcase_43 AC 218 ms
91,716 KB
testcase_44 AC 235 ms
92,696 KB
testcase_45 AC 226 ms
92,676 KB
testcase_46 AC 247 ms
93,240 KB
testcase_47 AC 251 ms
92,888 KB
testcase_48 AC 219 ms
93,124 KB
testcase_49 AC 193 ms
91,692 KB
testcase_50 AC 194 ms
91,444 KB
testcase_51 AC 192 ms
91,676 KB
testcase_52 AC 190 ms
91,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N,Q = map(int,input().split())

P = 998244353
G = [[] for _ in range(N)]

for _ in range(Q):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append((b,c))
    G[b].append((a,c))

ans = 1
mem = [-1] * N
for i in range(N):
    if mem[i] != -1:continue
    stack = []
    stack.append(i)
    mem[i] = 0
    while stack:
        now = stack.pop()
        for u,c in G[now]:
            if mem[u] == -1:
                mem[u] = mem[now] ^ c
                stack.append(u)
            else:
                if mem[u] != mem[now] ^ c:
                    print(0)
                    exit()
    ans = ans * 2 % P
print(ans)
0