結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
zaki_chemtech
|
| 提出日時 | 2020-07-10 20:51:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 263 ms / 2,000 ms |
| コード長 | 655 bytes |
| コンパイル時間 | 284 ms |
| コンパイル使用メモリ | 81,580 KB |
| 実行使用メモリ | 89,216 KB |
| 最終ジャッジ日時 | 2024-10-11 07:18:42 |
| 合計ジャッジ時間 | 3,933 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
from collections import deque
n = int(input())
root = [[] for i in range(n)]
for _ in range(n-1):
a, b = (int(x) for x in input().split())
root[b].append(a)
root[a].append(b)
stack=deque([0])
check = [-1]*n
check[0] = 1
while len(stack)>0:
v = stack.popleft()
for i in root[v]:
if check[i] == -1:
check[i]=check[v]+1
stack.append(i)
if n == 2 or -1 not in check:
print('Bob')
else:
count_1 = check.count(-1)
count_ren = 0
for i in root:
if len(i) < 2:
count_ren += 1
if count_1 < 2 and count_ren < 2:
print('Bob')
else:
print('Alice')
zaki_chemtech