結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー madoka
提出日時 2020-02-01 14:35:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,389 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 95,544 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 19:59:41
合計ジャッジ時間 2,080 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int par[100002];
int rk[100002];
int sz[100002];
void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i; sz[i]=1;
	}
}
 
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
 
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rk[x]<rk[y]){
		par[x]=y; sz[y]+=sz[x];
	}else{
		par[y]=x; sz[x]+=sz[y];
		if(rk[x]==rk[y]) rk[x]++;
	}
}
 
bool same(int x, int y){
	return find(x)==find(y);
}
int main()
{
  int N; cin>>N;
  ll ans[100002];
  int a[100002], b[100002];
  for(int i=0; i<N-1; i++){
    cin>>a[i]>>b[i];
  }
  init(N);
  ll c=0;
  for(int i=0; i<N-1; i++){
    int x=a[i], y=b[i];
    
	if(same(x, y)){
      continue;
    }
	
    x=find(x), y=find(y);
    unite(x, y);
  }
  //printf("%d",sz[0]);
	
	if(sz[0]==N){
		puts("Bob");
	}
	else{
		puts("Alice");
	}
	
	/*
	ll flg;
	flg=0;
	for(int i=0; i<N-2; i++){
		if(!same(i, i+1)){
      		flg=1;
    	}
	}
	if(flg==1){
		puts("Bob");
	}
	else{
		puts("Alice");
	}
	*/
  return 0;
}
0