結果
問題 | No.977 アリス仕掛けの摩天楼 |
ユーザー |
![]() |
提出日時 | 2020-02-06 00:08:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,362 bytes |
コンパイル時間 | 2,354 ms |
コンパイル使用メモリ | 167,332 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-23 08:02:29 |
合計ジャッジ時間 | 4,227 ms |
ジャッジサーバーID (参考情報) |
judge5 / 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); rep(i, 0, n - 1) { int u, v; cin >> u >> v; uf.unite(u, v); } set<int> cnt; rep(i, 0, n) cnt.insert(uf.find(i)); if(sz(cnt) >= 2) cout << "Alice" << endl; else cout << "Bob" << endl; return 0; }