結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー CleyLCleyL
提出日時 2020-01-31 21:53:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 78,924 KB
実行使用メモリ 9,152 KB
最終ジャッジ日時 2023-10-17 09:30:25
合計ジャッジ時間 2,269 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,976 KB
testcase_01 AC 4 ms
5,976 KB
testcase_02 AC 4 ms
5,976 KB
testcase_03 AC 4 ms
5,980 KB
testcase_04 AC 3 ms
5,980 KB
testcase_05 AC 4 ms
5,980 KB
testcase_06 AC 4 ms
5,980 KB
testcase_07 AC 3 ms
5,980 KB
testcase_08 AC 4 ms
5,980 KB
testcase_09 AC 4 ms
5,980 KB
testcase_10 WA -
testcase_11 AC 3 ms
5,980 KB
testcase_12 AC 3 ms
5,980 KB
testcase_13 AC 10 ms
6,336 KB
testcase_14 AC 11 ms
6,368 KB
testcase_15 AC 11 ms
6,368 KB
testcase_16 AC 10 ms
6,336 KB
testcase_17 AC 10 ms
6,328 KB
testcase_18 AC 25 ms
7,048 KB
testcase_19 WA -
testcase_20 AC 40 ms
7,484 KB
testcase_21 AC 68 ms
8,356 KB
testcase_22 AC 86 ms
9,100 KB
testcase_23 AC 88 ms
9,148 KB
testcase_24 AC 83 ms
9,152 KB
testcase_25 AC 85 ms
9,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
#include <vector>
using namespace std;
//B
struct UnionFind {
  vector<int> par;
  int N;
  UnionFind(int n) : N(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);
  }
  int size(){
    set<int> A;
    for(int i = 0; N > i; i++){
      A.insert(root(i));
    }
    return A.size();
  }

};
//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);
  }
  if(A.size() < 2){
    cout << "Bob" << endl;
  }else{
    cout << "Alice" << endl;
  }
}
0