結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
![]() |
提出日時 | 2020-07-10 20:29:25 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 606 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,052 KB |
実行使用メモリ | 89,584 KB |
最終ジャッジ日時 | 2024-10-11 07:17:50 |
合計ジャッジ時間 | 4,265 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 5 |
ソースコード
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-1].append(a-1) root[a-1].append(b-1) 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 = 0 for i in root: if len(i) < 2: count += 1 if 1 < count: print('Alice') else: print('Bob')