結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
![]() |
提出日時 | 2023-02-28 02:02:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,301 bytes |
コンパイル時間 | 3,636 ms |
コンパイル使用メモリ | 250,912 KB |
最終ジャッジ日時 | 2025-02-11 00:04:48 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.14159265359; ll inf=10010010010010010; ll mod=998244353; struct unionfind { vector<ll>par,siz; unionfind(ll n): par(n,-1),siz(n,1){} ll root(ll x){ if (par[x]==-1) { return x; }else{ return par[x]=root(par[x]); } } bool issame(ll x,ll y){ return root(x)==root(y); } bool unite(ll x,ll y){ x=root(x); y=root(y); if (x==y) { return false; } if (siz[x]<siz[y]) { swap(x,y); } par[y]=x; siz[x]+=siz[y]; return true; } ll size(ll x){ return siz[root(x)]; } }; int main(){ ll n; cin >> n; unionfind uf(n); vector<ll>u(n-1),v(n-1); for (ll i = 0; i < n-1; i++) { cin >> u[i] >> v[i]; uf.unite(u[i],v[i]); } ll ans=0; vector<ll>memo(n,0); for (ll i = 0; i < n; i++) { if (memo[uf.root(i)]==0) { ans+=1; } memo[uf.root(i)]+=1; } if (ans==1) { cout << "Bob" << endl; }else{ cout << "Alice" << endl; } }