結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
titia
|
| 提出日時 | 2020-01-31 21:29:38 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 750 bytes |
| コンパイル時間 | 157 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 29,056 KB |
| 最終ジャッジ日時 | 2024-09-17 07:13:10 |
| 合計ジャッジ時間 | 4,380 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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