結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー KodaiKodai
提出日時 2020-04-15 16:37:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 968 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 22,936 KB
最終ジャッジ日時 2024-04-09 18:46:28
合計ジャッジ時間 7,473 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
17,568 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 26 ms
10,880 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 28 ms
10,752 KB
testcase_12 AC 27 ms
10,752 KB
testcase_13 AC 78 ms
11,648 KB
testcase_14 AC 642 ms
11,900 KB
testcase_15 AC 644 ms
11,896 KB
testcase_16 AC 76 ms
11,776 KB
testcase_17 AC 62 ms
11,520 KB
testcase_18 AC 209 ms
13,184 KB
testcase_19 WA -
testcase_20 AC 216 ms
14,972 KB
testcase_21 AC 334 ms
16,360 KB
testcase_22 AC 429 ms
19,428 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
import sys

sys.setrecursionlimit(10**6)

N = int(input())


class UnionFind:
    def __init__(self, n):
        super().__init__()
        self.parent = [i for i in range(n)]

    def root(self, x):
        if self.parent[x] != x:
            return self.root(self.parent[x])
        else:
            return x

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            self.parent[rx] = ry


uni = UnionFind(N)
temp_list = [0 for i in range(N)]
for i in range(N-1):
    a, b = list(map(int, input().split()))
    uni.unite(b, a)
    temp_list[a] += 1
    temp_list[b] += 1

# print(uni.parent)
# print(temp_list)

count = Counter(uni.parent)
count2 = Counter(temp_list)
# print(count)

if len(count) == 1:
    print("Bob")
elif len(count) == 2:
    if len(count2) == 2 and 2 in count2 and 0 in count2:
        print("Bob")
    else:
        print("Alice")
else:
    print("Alice")
0