結果

問題 No.3340 Simple Graph Game
コンテスト
ユーザー n_bitand_n_per_3
提出日時 2025-11-14 00:18:12
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 788 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 113,980 KB
最終ジャッジ日時 2025-11-14 00:18:39
合計ジャッジ時間 11,775 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 21 RE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())

connect = [[] for _ in range(N)]
connect_inv = [[] for _ in range(N)]
deg = [0]*N  # 出次数

for _ in range(N):
    u,v = map(lambda x:int(x)-1,input().split())
    connect[u].append(v)
    connect_inv[v].append(u)
    deg[u] += 1

res = [None]*N

array = []
for i in range(N):
    if deg[i] == 0:
        array.append(i)
        res[i] = False


while array:
    v = array.pop()
    for u in connect_inv[v]:
        deg[u] -= 1
        if res[u] == None:
            if res[v] == False:
                res[u] = True
                array.append(u)
            elif deg[u] == 0:
                res[u] = False
                array.append(u)

if res[0] == True:
    print("Alice")
elif res[0] == False:
    print("Bob")
else:
    print("Draw")








0