結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー hedwig100hedwig100
提出日時 2020-04-08 11:32:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 449 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 26,572 KB
最終ジャッジ日時 2023-09-25 10:12:09
合計ジャッジ時間 6,280 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
15,704 KB
testcase_01 AC 50 ms
15,816 KB
testcase_02 AC 50 ms
15,636 KB
testcase_03 AC 50 ms
15,756 KB
testcase_04 AC 51 ms
15,804 KB
testcase_05 AC 52 ms
15,712 KB
testcase_06 AC 58 ms
15,756 KB
testcase_07 AC 48 ms
16,248 KB
testcase_08 AC 50 ms
16,260 KB
testcase_09 AC 49 ms
15,668 KB
testcase_10 AC 52 ms
16,084 KB
testcase_11 AC 51 ms
15,684 KB
testcase_12 AC 51 ms
16,160 KB
testcase_13 AC 80 ms
17,216 KB
testcase_14 AC 81 ms
17,444 KB
testcase_15 AC 82 ms
17,428 KB
testcase_16 AC 79 ms
17,156 KB
testcase_17 AC 82 ms
18,736 KB
testcase_18 AC 150 ms
19,204 KB
testcase_19 AC 166 ms
24,064 KB
testcase_20 AC 244 ms
22,852 KB
testcase_21 AC 335 ms
23,652 KB
testcase_22 AC 442 ms
25,936 KB
testcase_23 AC 446 ms
26,548 KB
testcase_24 AC 410 ms
26,572 KB
testcase_25 AC 449 ms
26,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

MAXN = 100005
G = [[] for _ in range(MAXN)]
visited = [0] * MAXN
def dfs(i):
    visited[i] = 1
    for e in G[i]:
        if visited[e]:
            continue
        dfs(e)

def main():
    n = int(input())
    inedge = [0] * n
    for _ in range(n - 1):
        a,b = map(int,input().split())
        G[a].append(b)
        G[b].append(a)
        inedge[a] += 1
        inedge[b] += 1
    
    cnt = 0
    for i in range(n):
        if visited[i] == 0:
            dfs(i)
            cnt += 1
    
    if cnt == 1:
        print('Bob')
        return
    elif cnt >= 3:
        print('Alice')
        return
    
    ans = 'Bob'
    for i in range(n):
        if inedge[i] == 1:
            ans = 'Alice'
            break
    print(ans) 

if __name__ =='__main__':
    main()  
0