結果

問題 No.3340 Simple Graph Game
コンテスト
ユーザー N-noa21
提出日時 2025-11-13 21:42:33
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WJ  
(最新)
AC  
(最初)
実行時間 -
コード長 879 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
最終ジャッジ日時 2026-07-16 19:22:10
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)

ソースコード

diff #
raw source code

N,M = map(int, input().split())
edge = [[] for i in range(N)]
r_edge = [[] for i in range(N)]
res_cnt = [0] * N
for i in range(M):
    u,v = map(int, input().split())
    u-=1;v-=1
    res_cnt[u] += 1
    edge[u].append(v)
    r_edge[v].append(u)

from collections import deque
que = deque([])
ans_l = [-1] * N
for i in range(N):
    if len(edge[i]) == 0:
        que.append(i)
        ans_l[i] = 0
#print(que)

while que:
    now = que.popleft()
    #print(now)
    for _next in r_edge[now]:
        if ans_l[now] == 0 and res_cnt[_next] > 0:
            ans_l[_next] = 1
            res_cnt[_next] = 0
        else:
            res_cnt[_next] -= 1

        if res_cnt[_next] == 0:
            if ans_l[_next] == -1:
                ans_l[_next] = 0
            que.append(_next)

if ans_l[0] == 0:
    print("Bob")
elif ans_l[0] == 1:
    print("Alice")
else:
    print("Draw")
0