結果
| 問題 | No.977 アリス仕掛けの摩天楼 |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-01-31 21:29:38 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 750 bytes |
| 記録 | |
| コンパイル時間 | 332 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 32,344 KB |
| 最終ジャッジ日時 | 2026-04-06 04:14:49 |
| 合計ジャッジ時間 | 5,306 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
n=int(input())
E=[tuple(map(int,input().split())) for i in range(n-1)]
# UnionFind
Group = [i for i in range(n)] # グループ分け
Nodes = [1]*n # 各グループのノードの数
def find(x):
while Group[x] != x:
x=Group[x]
return x
def Union(x,y):
if find(x) != find(y):
if Nodes[find(x)] < Nodes[find(y)]:
Nodes[find(y)] += Nodes[find(x)]
Nodes[find(x)] = 0
Group[find(x)] = find(y)
else:
Nodes[find(x)] += Nodes[find(y)]
Nodes[find(y)] = 0
Group[find(y)] = find(x)
for x,y in E:
Union(x,y)
if max(Nodes)==n:
print("Bob")
elif max(Nodes)==n-1 and n==3:
print("Bob")
else:
print("Alice")
titia