結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー maspymaspy
提出日時 2020-01-31 22:53:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 37,436 KB
最終ジャッジ日時 2023-10-17 11:36:53
合計ジャッジ時間 3,188 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,196 KB
testcase_01 AC 27 ms
10,196 KB
testcase_02 AC 27 ms
10,196 KB
testcase_03 AC 27 ms
10,196 KB
testcase_04 AC 27 ms
10,196 KB
testcase_05 AC 27 ms
10,196 KB
testcase_06 AC 28 ms
10,196 KB
testcase_07 AC 28 ms
10,200 KB
testcase_08 AC 27 ms
10,200 KB
testcase_09 AC 27 ms
10,200 KB
testcase_10 AC 27 ms
10,200 KB
testcase_11 AC 28 ms
10,200 KB
testcase_12 AC 29 ms
10,200 KB
testcase_13 AC 45 ms
12,816 KB
testcase_14 AC 45 ms
12,816 KB
testcase_15 AC 45 ms
12,816 KB
testcase_16 AC 45 ms
12,816 KB
testcase_17 AC 45 ms
12,816 KB
testcase_18 AC 83 ms
18,304 KB
testcase_19 AC 86 ms
18,304 KB
testcase_20 AC 121 ms
23,308 KB
testcase_21 AC 181 ms
30,940 KB
testcase_22 AC 237 ms
36,340 KB
testcase_23 AC 240 ms
37,436 KB
testcase_24 AC 228 ms
37,436 KB
testcase_25 AC 246 ms
37,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
UV = zip(m,m)

graph = [[] for _ in range(N)]
for u,v in UV:
    graph[u].append(v)
    graph[v].append(u)

comp = [0] * N
c = 0
for v in range(N):
    if comp[v]:
        continue
    c += 1
    comp[v] = c
    stack = [v]
    while stack:
        v = stack.pop()
        for w in graph[v]:
            if comp[w]:
                continue
            comp[w] = c
            stack.append(w)

n = max(comp)
if n >= 3:
    print('Alice')
    exit()
if n == 1:
    print('Bob')
    exit()

deg = [len(x) for x in graph]
if any(x == 1 for x in deg):
    print('Alice')
else:
    print('Bob')
0