結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| コンテスト | |
| ユーザー |
utouto97
|
| 提出日時 | 2020-02-06 21:53:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,547 bytes |
| コンパイル時間 | 1,392 ms |
| コンパイル使用メモリ | 167,708 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 06:55:03 |
| 合計ジャッジ時間 | 2,976 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
/*
*/
using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int, int>;
class UnionFind {
public:
int n;
vector<int> par, rnk;
UnionFind(int n_) {
n = n_;
par.resize(n);
rnk.resize(n);
for (int i = 0; i < n; i++) {
par[i] = i;
rnk[i] = 0;
}
}
int find(int x) {
if (par[x] == x)
return x;
return par[x] = find(par[x]);
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (rnk[x] < rnk[y]) {
par[x] = y;
} else {
par[y] = x;
if (rnk[x] == rnk[y])
rnk[x]++;
}
}
bool same(int x, int y) { return find(x) == find(y); }
};
signed main() {
int n;
cin >> n;
UnionFind uf(n);
vi d(n);
rep(i, 0, n - 1) {
int u, v;
cin >> u >> v;
uf.unite(u, v);
d[u]++;
d[v]++;
}
set<int> cnt;
bool d1 = false;
rep(i, 0, n) {
cnt.insert(uf.find(i));
if (d[i] != 0 and d[i] != 2)
d1 = true;
}
if (sz(cnt) >= 2)
cout << "Alice" << endl;
else if (sz(cnt) == 2 and d1)
cout << "Alice" << endl;
else
cout << "Bob" << endl;
return 0;
}
utouto97