結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー ronpooronpoo
提出日時 2023-10-31 11:17:17
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 691 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 101,352 KB
最終ジャッジ日時 2023-10-31 11:17:22
合計ジャッジ時間 5,120 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,596 KB
testcase_01 AC 35 ms
53,596 KB
testcase_02 AC 34 ms
53,596 KB
testcase_03 AC 35 ms
53,596 KB
testcase_04 AC 39 ms
53,596 KB
testcase_05 AC 35 ms
53,596 KB
testcase_06 AC 35 ms
53,596 KB
testcase_07 AC 36 ms
53,596 KB
testcase_08 AC 37 ms
53,596 KB
testcase_09 AC 36 ms
53,596 KB
testcase_10 AC 37 ms
53,632 KB
testcase_11 AC 37 ms
53,596 KB
testcase_12 AC 36 ms
53,632 KB
testcase_13 AC 108 ms
78,992 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 109 ms
79,032 KB
testcase_17 RE -
testcase_18 AC 142 ms
84,112 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 221 ms
94,096 KB
testcase_22 AC 256 ms
101,352 KB
testcase_23 AC 264 ms
100,356 KB
testcase_24 AC 260 ms
100,888 KB
testcase_25 AC 251 ms
100,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
UV = [list(map(int, input().split())) for _ in range(N-1)]

comp = [-1] * N
compn = [0] * N
G = [[] for _ in range(N)]
for i in range(N-1):
    u, v = UV[i]
    G[u].append(v)
    G[v].append(u)
    compn[u] += 1
    compn[v] += 1

def dfs(now):
    for nxt in G[now]:
        if comp[nxt] != -1:
            continue
        comp[nxt] = comp[now]
        dfs(nxt)

cnt = 0
for i in range(N):
    if comp[i] != -1:
        continue
    cnt += 1
    comp[i] = cnt
    dfs(i)
    
if max(comp) == 1:    
    print('Bob')
elif max(comp) >= 3:
    print('Alice')
else:
    if all([False if x == 1 else True for x in compn]):
        print('Bob')
    else:
        print('Alice')
0