結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
kenta255
|
| 提出日時 | 2020-02-01 00:39:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 721 bytes |
| コンパイル時間 | 2,268 ms |
| コンパイル使用メモリ | 198,224 KB |
| 最終ジャッジ日時 | 2025-01-08 21:28:56 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class UnionFind{
public:
vector<int> par,siz;
UnionFind(int n_){init(n_);}
void init(int n = 1) {
siz.resize(n,1);
par.resize(n);
for (int i = 0; i < n; ++i) par[i] = i;
}
int root(int x = 1){
if(par[x]==x)return x;
return par[x] = root(par[x]);
}
void unite(int x = 1,int y = 1){
x = root(x);
y = root(y);
if(x==y)return;
siz[y] += siz[x];
siz[x] = 0;
par[x] = y;
}
int size(int x){
return siz[root(x)];
}
};
int main(){
ll N,u,v;
cin >> N;
UnionFind uf(N);
for (int i = 0; i < N-1; ++i){
cin >> u >> v;
uf.unite(u,v);
}
if(uf.size(0)==N){
cout << "Bob" << endl;
}else{
cout << "Alice" << endl;
}
}
kenta255