結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー c-yanc-yan
提出日時 2020-02-02 16:25:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 11,976 KB
最終ジャッジ日時 2023-10-19 01:16:12
合計ジャッジ時間 4,254 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,052 KB
testcase_01 AC 30 ms
10,052 KB
testcase_02 AC 31 ms
10,052 KB
testcase_03 AC 30 ms
10,052 KB
testcase_04 AC 32 ms
10,052 KB
testcase_05 AC 29 ms
10,052 KB
testcase_06 AC 30 ms
10,052 KB
testcase_07 AC 31 ms
10,052 KB
testcase_08 AC 31 ms
10,052 KB
testcase_09 AC 31 ms
10,052 KB
testcase_10 WA -
testcase_11 AC 33 ms
10,052 KB
testcase_12 AC 34 ms
10,052 KB
testcase_13 AC 64 ms
10,244 KB
testcase_14 AC 64 ms
10,208 KB
testcase_15 AC 65 ms
10,212 KB
testcase_16 AC 63 ms
10,244 KB
testcase_17 AC 61 ms
10,276 KB
testcase_18 AC 129 ms
10,396 KB
testcase_19 WA -
testcase_20 AC 191 ms
10,920 KB
testcase_21 AC 288 ms
11,448 KB
testcase_22 AC 366 ms
11,976 KB
testcase_23 AC 403 ms
11,976 KB
testcase_24 AC 377 ms
11,712 KB
testcase_25 AC 412 ms
11,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j

setrecursionlimit(10 ** 5)

N = int(input())

parent = [-1] * N
for _ in range(N - 1):
    u, v = map(int, input().split())
    unite(parent, u, v)

t = sum(1 for e in parent if e < 0)

if t == 1:
    print('Bob')
else:
    print('Alice')
0