結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-20 17:22:01 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 991 bytes |
| コンパイル時間 | 391 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 28,928 KB |
| 最終ジャッジ日時 | 2024-06-20 17:22:07 |
| 合計ジャッジ時間 | 5,836 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
def find(parent, i):
if parent[i] == i:
return i
else:
return find(parent, parent[i])
def union(parent, rank, x, y):
xroot = find(parent, x)
yroot = find(parent, y)
if xroot != yroot:
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot
elif rank[xroot] > rank[yroot]:
parent[yroot] = xroot
else:
parent[yroot] = xroot
rank[xroot] += 1
def ist(N, edges):
parent = list(range(N))
rank = [0] * N
for u, v in edges:
if find(parent, u) == find(parent, v):
return False
else:
union(parent, rank, u, v)
root = find(parent, 0)
for i in range(1, N):
if find(parent, i) != root:
return False
return True
N = int(input().strip())
edges = []
for _ in range(N - 1):
u, v = map(int, input().strip().split())
edges.append((u, v))
if ist(N, edges):
print("Bob")
else:
print("Alice")