結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
![]() |
提出日時 | 2020-01-31 21:33:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 708 bytes |
コンパイル時間 | 1,326 ms |
コンパイル使用メモリ | 168,712 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 07:18:01 |
合計ジャッジ時間 | 2,225 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> t; UnionFind(int n) : t(n, -1) {} 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; } 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.size(0) == n) { cout << "Bob\n"; } else { cout << "Alice\n"; } }