結果
| 問題 |
No.3340 Simple Graph Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-13 21:42:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 379 ms / 2,000 ms |
| コード長 | 879 bytes |
| コンパイル時間 | 133 ms |
| コンパイル使用メモリ | 82,272 KB |
| 実行使用メモリ | 119,704 KB |
| 最終ジャッジ日時 | 2025-11-18 10:37:28 |
| 合計ジャッジ時間 | 10,574 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 59 |
ソースコード
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")