結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-12 15:38:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,877 bytes |
| コンパイル時間 | 2,072 ms |
| コンパイル使用メモリ | 173,280 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 03:57:06 |
| 合計ジャッジ時間 | 3,534 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)
using ll = long long ;
using ld = long double;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
class DisjointSet {
public:
vector<int> rank, p, size;
DisjointSet() {}
DisjointSet(int s) {
rank.resize(s, 0);
p.resize(s, 0);
size.resize(s, 0);
rep (i, s) init(i);
}
void init(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
bool isSame(int x, int y) {
return root(x) == root(y);
}
void makeSet(int x, int y) {
if (isSame(x, y)) return;
link(root(x), root(y));
}
void link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
} else {
p[x] = y;
size[y] += size[x];
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
int root(int x) {
if (x != p[x]) {
p[x] = root(p[x]);
}
return p[x];
}
int getSize(int x) {
return size[root(x)];
}
};
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(0);
int n;
cin >> n;
DisjointSet dj = DisjointSet(n);
rep (i, n - 1) {
int u, v;
cin >> u >> v;
dj.makeSet(u, v);
}
vector<int> p(n);
rep (i, n) p[dj.root(i)]++;
int mx = 0;
rep (i, n) mx = max(mx, p[i]);
if (n - mx >= 1) cout << "Alice" << endl;
else cout << "Bob" << endl;
return 0;
}