結果
| 問題 | No.977 アリス仕掛けの摩天楼 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-19 04:37:01 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 645 bytes |
| 記録 | |
| コンパイル時間 | 681 ms |
| コンパイル使用メモリ | 20,704 KB |
| 実行使用メモリ | 18,396 KB |
| 最終ジャッジ日時 | 2026-05-24 21:32:06 |
| 合計ジャッジ時間 | 9,169 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
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
def main():
N = int(input())
uf = UnionFind(N)
for _ in range(N-1):
u, v = map(int, input().split())
uf.union(u, v)
p = uf.find(0)
bob = all(uf.find(i) == p for i in range(N))
print('Bob' if bob else 'Alice')
main()