結果
| 問題 | No.3340 Simple Graph Game |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-12-05 03:53:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 847 bytes |
| 記録 | |
| コンパイル時間 | 354 ms |
| コンパイル使用メモリ | 82,232 KB |
| 実行使用メモリ | 134,628 KB |
| 最終ジャッジ日時 | 2025-12-05 03:53:34 |
| 合計ジャッジ時間 | 4,518 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 58 |
ソースコード
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
E=[[] for i in range(N)]
E_INV=[[] for i in range(N)]
for i in range(M):
x,y=map(int,input().split())
x-=1
y-=1
E[x].append(y)
E_INV[y].append(x)
ANS=[-1]*N
Q0=[]
Q1=[]
for i in range(N):
if E[i]==[]:
ANS[i]=0
Q0.append(i)
while Q0 or Q1:
while Q0:
x=Q0.pop()
for to in E_INV[x]:
ANS[to]=1
Q1.append(to)
if Q1:
x=Q1.pop()
for to in E_INV[x]:
if ANS[to]!=-1:
continue
L=set()
for toto in E[to]:
L.add(ANS[toto])
if L=={1}:
ANS[to]=0
Q0.append(to)
if ANS[0]==0:
print("Bob")
elif ANS[0]==1:
print("Alice")
else:
print("Draw")
titia