結果
| 問題 | No.3695 同室と別室 |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-10-22 02:40:26 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 509 ms / 2,000 ms |
| + 741µs | |
| コード長 | 989 bytes |
| 記録 | |
| コンパイル時間 | 554 ms |
| コンパイル使用メモリ | 14,848 KB |
| 実行使用メモリ | 65,280 KB |
| 最終ジャッジ日時 | 2026-10-22 02:40:41 |
| 合計ジャッジ時間 | 3,661 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
import sys
input = sys.stdin.readline
N,Q=list(map(int,input().split()))
E1=[[] for i in range(N)]
E2=[[] for i in range(N)]
for i in range(Q):
t,a,b=list(map(int,input().split()))
a-=1
b-=1
if t==0:
E1[a].append(b)
E1[b].append(a)
else:
E2[a].append(b)
E2[b].append(a)
flag=1
A=[-1]*N
score=0
for i in range(N):
if A[i]==-1:
score+=1
A[i]=0
Q=[i]
while Q:
x=Q.pop()
for to in E1[x]:
if A[to]==-1:
A[to]=A[x]
Q.append(to)
else:
if A[to]!=A[x]:
flag=0
for to in E2[x]:
if A[to]==-1:
A[to]=A[x]^1
Q.append(to)
else:
if A[to]==A[x]:
flag=0
mod=998244353
if flag:
print(pow(2,score,mod))
else:
print(0)
titia