結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
|
| 提出日時 | 2020-04-15 16:20:31 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 804 bytes |
| コンパイル時間 | 109 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 19,156 KB |
| 最終ジャッジ日時 | 2024-10-01 18:48:24 |
| 合計ジャッジ時間 | 5,444 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 4 RE * 6 |
ソースコード
from collections import Counter
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)
# print(count)
if len(count) == 1:
print("Bob")
elif len(count) == 2:
print("Bob")
else:
print("Alice")