結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
👑 |
提出日時 | 2020-01-31 21:42:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,007 bytes |
コンパイル時間 | 961 ms |
コンパイル使用メモリ | 72,104 KB |
実行使用メモリ | 9,088 KB |
最終ジャッジ日時 | 2024-09-17 07:31:30 |
合計ジャッジ時間 | 2,326 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
#include <iostream> #include <vector> using namespace std; //B struct UnionFind { vector<int> par; UnionFind(int n) : par(n){ for(int i = 0; n > i; i++)par[i] = i; } int root(int n){ if(par[n] == n)return n; return par[n] = root(par[n]); } void unite(int a,int b){ int ra = root(a); int rb = root(b); if(ra==rb)return; par[ra] = rb; } bool same(int a, int b){ return root(a) == root(b); } }; //E int main(){ int n;cin>>n; UnionFind A(n); vector<int> Z[100000]; for(int i = 0; n-1 > i; i++){ int a,b;cin>>a>>b; A.unite(a,b); Z[a].push_back(b); Z[b].push_back(a); } bool nya = false; for(int i = 1; n > i; i++){ if(!A.same(0,i)){ nya = true; break; } } int nw = 0; bool z = false; for(int i = 0; n > i; i++){ if(0 == Z[i].size()){ nw++; }else if(1 == Z[i].size()){ z = true; } } if((nya+z)+nw > 1){ cout << "Alice" << endl; }else{ cout << "Bob" << endl; } }