結果
| 問題 | 
                            No.977 アリス仕掛けの摩天楼
                             | 
                    
| コンテスト | |
| ユーザー | 
                             oxyshower
                         | 
                    
| 提出日時 | 2020-02-01 15:09:46 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 950 bytes | 
| コンパイル時間 | 1,792 ms | 
| コンパイル使用メモリ | 171,340 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-18 20:02:00 | 
| 合計ジャッジ時間 | 2,916 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 24 WA * 2 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
struct UnionFind{
  vector<int> par; //親
  vector<int> size; //集合の大きさ
  UnionFind(int n){
    par.resize(n); size.resize(n, 1);
    for(int i = 0; i < n; i++){
      par[i] = i;
    }
  }
  //木の根を求める
  int root(int x){
    if(par[x] == x){
      return x;
    }else{
      return par[x] = root(par[x]);
    }
  }
  //xとyの属する集合を併合
  void unite(int x,int y){
    x = root(x), y = root(y);
    if(x == y) return;
    if(size[x] < size[y]) swap(x,y);
    par[y] = x;
    size[x] += size[y];
  }
  bool same(int x, int y){
    return root(x) == root(y);
  }
};
signed main(){
  int n; cin >> n;
  UnionFind uf(n);
  for(int i = 0; i < n-1; i++){
    int u, v; cin >> u >> v;
    uf.unite(u, v);
  }
  cout << (uf.size[uf.root(0)] == n ? "Bob" : "Alice") << endl;
  return 0;
}
            
            
            
        
            
oxyshower