結果

問題 No.2277 Honest or Dishonest ?
ユーザー とりゐとりゐ
提出日時 2023-04-21 23:05:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 82,156 KB
実行使用メモリ 92,744 KB
最終ジャッジ日時 2024-04-25 19:06:29
合計ジャッジ時間 8,609 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,564 KB
testcase_01 AC 36 ms
53,244 KB
testcase_02 AC 35 ms
52,744 KB
testcase_03 AC 156 ms
87,644 KB
testcase_04 AC 177 ms
89,800 KB
testcase_05 AC 103 ms
82,396 KB
testcase_06 AC 136 ms
85,496 KB
testcase_07 AC 117 ms
83,692 KB
testcase_08 AC 100 ms
82,708 KB
testcase_09 AC 133 ms
86,344 KB
testcase_10 AC 100 ms
81,904 KB
testcase_11 AC 79 ms
78,860 KB
testcase_12 AC 90 ms
79,928 KB
testcase_13 AC 147 ms
86,248 KB
testcase_14 AC 91 ms
80,448 KB
testcase_15 AC 103 ms
81,640 KB
testcase_16 AC 121 ms
83,276 KB
testcase_17 AC 84 ms
78,848 KB
testcase_18 AC 163 ms
89,428 KB
testcase_19 AC 168 ms
89,460 KB
testcase_20 AC 137 ms
84,932 KB
testcase_21 AC 115 ms
81,408 KB
testcase_22 AC 123 ms
84,564 KB
testcase_23 AC 132 ms
84,780 KB
testcase_24 AC 146 ms
84,504 KB
testcase_25 AC 126 ms
87,216 KB
testcase_26 AC 86 ms
82,372 KB
testcase_27 AC 93 ms
81,108 KB
testcase_28 AC 100 ms
81,412 KB
testcase_29 AC 113 ms
85,096 KB
testcase_30 AC 80 ms
79,168 KB
testcase_31 AC 107 ms
84,000 KB
testcase_32 AC 112 ms
84,892 KB
testcase_33 AC 155 ms
89,108 KB
testcase_34 AC 145 ms
87,748 KB
testcase_35 AC 77 ms
79,648 KB
testcase_36 AC 109 ms
82,996 KB
testcase_37 AC 131 ms
85,284 KB
testcase_38 AC 68 ms
77,588 KB
testcase_39 AC 76 ms
78,068 KB
testcase_40 AC 79 ms
79,268 KB
testcase_41 AC 150 ms
88,384 KB
testcase_42 AC 118 ms
83,940 KB
testcase_43 AC 164 ms
90,664 KB
testcase_44 AC 198 ms
92,744 KB
testcase_45 AC 192 ms
92,340 KB
testcase_46 AC 189 ms
92,732 KB
testcase_47 AC 190 ms
92,368 KB
testcase_48 AC 193 ms
92,388 KB
testcase_49 AC 164 ms
91,296 KB
testcase_50 AC 153 ms
90,632 KB
testcase_51 AC 152 ms
90,356 KB
testcase_52 AC 154 ms
90,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
input=lambda :stdin.readline()[:-1]

n,q=map(int,input().split())
edge=[[] for i in range(n)]
for _ in range(q):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  edge[a].append((b,c))
  edge[b].append((a,c))

seen=[-1]*n
mod=998244353
ans=1
for i in range(n):
  if seen[i]!=-1:
    continue
  seen[i]=0
  todo=[i]
  while todo:
    v=todo.pop()
    for u,c in edge[v]:
      if seen[u]==-1:
        seen[u]=seen[v]^c
        todo.append(u)
      elif seen[v]^c!=seen[u]:
        print(0)
        exit()
  ans*=2
  ans%=mod

print(ans%mod)
0