結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー bachoppibachoppi
提出日時 2020-01-31 23:10:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,396 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 101,112 KB
実行使用メモリ 9,668 KB
最終ジャッジ日時 2023-10-17 12:14:58
合計ジャッジ時間 2,498 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 9 ms
4,348 KB
testcase_15 AC 9 ms
4,348 KB
testcase_16 AC 9 ms
4,348 KB
testcase_17 AC 9 ms
4,348 KB
testcase_18 AC 24 ms
5,548 KB
testcase_19 AC 25 ms
5,532 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 101 ms
9,668 KB
testcase_24 AC 92 ms
9,668 KB
testcase_25 AC 102 ms
9,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

struct UnionFind{
	vector<int> par,siz;
	UnionFind(int N): par(N), siz(N){
		rep(i, N){
			par[i] = i; siz[i] = 1;
		}
	}
	int root(int x){
		if(par[x]==x) return x;
		else return root(par[x]);
	}
	void unite(int x, int y){
		x=root(x); y=root(y);
		if(x==y) return;
		if(siz[x] < siz[y]) swap(x, y);
		par[y] = x;
		siz[x] += siz[y];
	}
	bool same(int x, int y){
		return root(x)==root(y);
	}
	int size(int x){
		return siz[root(x)];
	}
};

int main(){
  int N; cin >> N; vector<int> to[N];
  UnionFind uf(N);
  rep(i, N-1){
    int u, v; cin >> u >> v;
    to[u].push_back(v); to[v].push_back(u);
    uf.unite(u, v);
  }
  int one=0, two=0;
  rep(i, N){
    if(to[i].size()==1) one++;
    else if(to[i].size()==2) two++; 
  }
  bool can = false;
  if(uf.size(0)==N) can=true;
  if(two==N-1) can=true;
  if(can) cout << "Bob" << endl;
  else cout << "Alice" << endl;
}
0