結果
| 問題 | No.2277 Honest or Dishonest ? |
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2023-04-21 21:57:51 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 539 ms / 2,000 ms |
| コード長 | 457 bytes |
| 記録 | |
| コンパイル時間 | 551 ms |
| コンパイル使用メモリ | 20,572 KB |
| 実行使用メモリ | 43,868 KB |
| 最終ジャッジ日時 | 2026-05-08 12:30:44 |
| 合計ジャッジ時間 | 20,178 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
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)
ニックネーム