結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー zaki_chemtechzaki_chemtech
提出日時 2020-07-10 20:29:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 89,156 KB
最終ジャッジ日時 2024-04-19 15:06:06
合計ジャッジ時間 4,813 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,120 KB
testcase_01 AC 41 ms
53,632 KB
testcase_02 AC 41 ms
53,760 KB
testcase_03 AC 41 ms
53,504 KB
testcase_04 AC 41 ms
53,760 KB
testcase_05 AC 41 ms
54,016 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 46 ms
54,144 KB
testcase_09 AC 42 ms
54,144 KB
testcase_10 AC 42 ms
54,144 KB
testcase_11 AC 42 ms
54,272 KB
testcase_12 AC 41 ms
54,272 KB
testcase_13 AC 105 ms
77,568 KB
testcase_14 AC 103 ms
77,312 KB
testcase_15 AC 104 ms
77,568 KB
testcase_16 AC 99 ms
77,568 KB
testcase_17 AC 102 ms
77,568 KB
testcase_18 AC 134 ms
80,256 KB
testcase_19 AC 137 ms
80,128 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 271 ms
88,832 KB
testcase_24 AC 264 ms
89,156 KB
testcase_25 AC 277 ms
88,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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')
0