結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-17 13:27:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,767 bytes |
| コンパイル時間 | 2,302 ms |
| コンパイル使用メモリ | 197,724 KB |
| 最終ジャッジ日時 | 2025-02-15 15:25:11 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, r) for(int i = 0; i < (r); ++i)
#define reps(i, s, r) for(int i = (s); i < (r); ++i)
#define fore(i, m2) for(auto &i : m2)
#define vi vector<int>
#define vl vector<ll>
#define pl pair<ll, ll>
#define all(i) (i).begin(), (i).end()
#define fs first
#define sc second
template <class T> bool chmin(T &i, T b) {
if(i > b) {
i = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
const ll INF = LONG_LONG_MAX / 3;
const ll MOD = 1'000'000'007;
const ll MAX = 1e3 + 5;
class unionFind {
public:
vi rank, p;
unionFind() {}
unionFind(int size) {
rank.resize(size, 0);
p.resize(size, 0);
rep(i, size) makeSet(i);
}
void makeSet(int x) {
p[x] = x;
rank[x] = 0;
}
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y) { link(root(x), root(y)); }
void link(int x, int y) {
if(rank[x] > rank[y]) {
p[y] = x;
} else {
p[x] = y;
if(rank[x] == rank[y]) {
rank[y]++;
}
}
}
int root(int x) {
if(x != p[x]) {
p[x] = root(p[x]);
}
return p[x];
}
};
int main() {
ll n;
cin >> n;
unionFind uf(n);
ll u, v;
rep(i, n - 1) {
cin >> u >> v;
uf.unite(u, v);
}
bool res = true;
rep(i, n - 1) {
if(uf.root(i) != uf.root(i + 1))
res = false;
}
if(res)
cout << "Bob" << endl;
else
cout << "Alice" << endl;
}