結果

問題 No.3340 Simple Graph Game
コンテスト
ユーザー flippergo
提出日時 2026-02-04 21:19:12
言語 PyPy3
(7.3.17)
結果
AC  
実行時間 757 ms / 2,000 ms
コード長 784 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 442 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 142,692 KB
最終ジャッジ日時 2026-02-04 21:19:41
合計ジャッジ時間 19,461 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 59
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque
N,M = map(int,input().split())
G = {i:[[],[]] for i in range(1,N+1)}
outdeg = [0]*(N+1)
for _ in range(M):
    u,v = map(int,input().split())
    G[u][1].append(v)
    outdeg[u] += 1
    G[v][0].append(u)
A = [-1]*(N+1)
que = deque([])
for i in range(1,N+1):
    if not G[i][1]:
        que.append(i)
        A[i] = 0
while que:
    i = que.popleft()
    for j in G[i][0]:
        if outdeg[j]==0:continue
        if A[i]==0:
            if A[j]==-1:
                A[j] = 1
                outdeg[j] = 0
                que.append(j)
        elif A[i]==1:
            outdeg[j] -= 1
            if outdeg[j]==0:
                A[j] = 0
                que.append(j)
if A[1]==1:
    print("Alice")
elif A[1]==0:
    print("Bob")
else:
    print("Draw")
0