結果
| 問題 | No.2277 Honest or Dishonest ? |
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2023-04-21 21:57:51 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 488 ms / 2,000 ms |
| + 263µs | |
| コード長 | 457 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 15,104 KB |
| 実行使用メモリ | 40,704 KB |
| 最終ジャッジ日時 | 2026-09-21 03:23:37 |
| 合計ジャッジ時間 | 19,462 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
ニックネーム