結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
![]() |
提出日時 | 2020-01-31 21:37:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 726 bytes |
コンパイル時間 | 1,548 ms |
コンパイル使用メモリ | 168,016 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-17 07:23:19 |
合計ジャッジ時間 | 2,614 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> t; int c; UnionFind(int n) : t(n, -1), c(n) {} int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); } void unite(int u, int v) { if ((u = find(u)) == (v = find(v))) return; if (-t[u] < -t[v]) swap(u, v); t[u] += t[v]; t[v] = u; --c; } bool same(int u, int v) { return find(u) == find(v); } int size(int v) { return -t[find(v)]; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; UnionFind uf(n); for (int _ = n - 1; _--; ) { int u, v; cin >> u >> v; uf.unite(u, v); } if (uf.c == 1) { cout << "Bob\n"; } else { cout << "Alice\n"; } }