結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
uw_yu1rabbit
|
| 提出日時 | 2020-08-21 19:27:31 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,353 bytes |
| コンパイル時間 | 4,253 ms |
| コンパイル使用メモリ | 101,184 KB |
| 最終ジャッジ日時 | 2025-01-13 04:49:54 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
template <typename T>
class UnionFind
{
public:
vector<T> par;
UnionFind(T n) : par(n, -1) {}
void init(T n)
{
for (i32 i = 0; i < n; i++)
{
par[i] = -1;
}
}
i64 root(T x)
{
if (par[x] < 0)
return x;
else
return par[x] = root(par[x]);
}
bool same(T x, T y)
{
return root(x) == root(y);
}
bool merge(T x, T y)
{
x = root(x);
y = root(y);
if (x == y)
return false;
if (par[x] > par[y])
swap(x, y);
par[x] += par[y];
par[y] = x;
return true;
}
i64 size(T x)
{
return -par[root(x)];
}
};
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n;
cin >> n;
UnionFind uft(n);
rep(i,n - 1){
i64 u,v;
cin >> u >> v;
uft.merge(u,v);
}
i64 cnt = 0;
rep(i,n){
if(uft.size(i) == n) cnt++;
}
cout << (cnt == n ? "Bob" : "Alice") << endl;
}
uw_yu1rabbit