結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー madokamadoka
提出日時 2020-02-01 14:35:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,389 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 97,508 KB
実行使用メモリ 5,596 KB
最終ジャッジ日時 2023-10-19 00:00:49
合計ジャッジ時間 2,108 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,432 KB
testcase_01 AC 2 ms
4,432 KB
testcase_02 AC 2 ms
4,432 KB
testcase_03 AC 2 ms
4,432 KB
testcase_04 AC 2 ms
4,432 KB
testcase_05 AC 3 ms
4,432 KB
testcase_06 AC 3 ms
4,432 KB
testcase_07 AC 2 ms
4,432 KB
testcase_08 AC 2 ms
4,432 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,432 KB
testcase_12 AC 2 ms
4,432 KB
testcase_13 AC 8 ms
4,548 KB
testcase_14 AC 8 ms
4,548 KB
testcase_15 AC 7 ms
4,548 KB
testcase_16 AC 7 ms
4,548 KB
testcase_17 AC 7 ms
4,548 KB
testcase_18 AC 19 ms
4,784 KB
testcase_19 WA -
testcase_20 AC 30 ms
4,996 KB
testcase_21 AC 45 ms
5,312 KB
testcase_22 AC 58 ms
5,548 KB
testcase_23 WA -
testcase_24 AC 61 ms
5,596 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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