結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
cotton_fn_
|
| 提出日時 | 2020-01-31 23:02:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,590 bytes |
| コンパイル時間 | 1,090 ms |
| コンパイル使用メモリ | 120,548 KB |
| 最終ジャッジ日時 | 2025-01-08 21:23:21 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 5 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T> T iabs(const T& x) { return max(x, -x); }
struct UnionFind {
vector<int> p, s;
UnionFind(size_t n) : p(n, -1), s(n, 1) {}
int root(int u) {
while (p[u] != -1) u = p[u];
return u;
}
bool same(int i, int j) {
return root(i) == root(j);
}
void unite(int u, int v) {
u = root(u); v = root(v);
if (u != v) {
if (s[u] < s[v]) swap(u, v);
p[v] = u;
s[u] += s[v];
}
}
int size(int i) {
return s[root(i)];
}
};
int n;
int main() {
cin >> n;
vector<int> deg(n);
UnionFind uf(n);
for (int i = 0; i < n - 1; ++i) {
int u, v;
cin >> u >> v;
deg[u]++;
deg[v]++;
uf.unite(u, v);
}
if (uf.size(0) == n) {
cout << "Bob\n";
return 0;
}
int cnt0 = 0, cnt2 = 0;
for (int u = 0; u < n; ++u) {
if (deg[u] == 0) {
++cnt0;
}
if (deg[u] == 2) {
++cnt2;
}
}
if (cnt0 == 1 && cnt2 == n - 1) {
cout << "Bob\n";
return 0;
}
cout << "Alice\n";
return 0;
}
cotton_fn_