結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー yomo3yomo3
提出日時 2020-02-20 20:01:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 605 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 14,720 KB
最終ジャッジ日時 2024-04-17 06:28:56
合計ジャッジ時間 4,894 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 31 ms
10,752 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 WA -
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 66 ms
11,264 KB
testcase_14 AC 68 ms
11,136 KB
testcase_15 AC 67 ms
11,136 KB
testcase_16 AC 67 ms
11,136 KB
testcase_17 AC 68 ms
11,264 KB
testcase_18 AC 141 ms
12,032 KB
testcase_19 WA -
testcase_20 AC 211 ms
12,672 KB
testcase_21 AC 321 ms
13,952 KB
testcase_22 AC 410 ms
14,720 KB
testcase_23 AC 503 ms
14,720 KB
testcase_24 AC 458 ms
14,592 KB
testcase_25 AC 501 ms
14,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

N = int(input())
uf = UnionFind(N)
for i in range(N-1):
    u, v = map(int, input().split())
    uf.union(u, v)

first = uf.find(0)
bob = all(uf.find(i) == first for i in range(1, N))

print('Bob' if bob else 'Alice')
0