結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー hig98ingrohig98ingro
提出日時 2020-01-31 21:38:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 980 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 170,184 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 08:57:17
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge14 / 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 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 8 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 12 ms
4,348 KB
testcase_21 AC 18 ms
4,348 KB
testcase_22 AC 23 ms
4,348 KB
testcase_23 AC 26 ms
4,348 KB
testcase_24 AC 24 ms
4,348 KB
testcase_25 AC 26 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
ll i, j, k,ans;
//Union木
struct UnionFind{
    vector<int> nxt;
    void init(int x){
        nxt.clear();
        nxt.resize(x);
        for (int i = 0; i < x;i++){
            nxt[i] = i;
        }
    }
    int find(int x){
        if(nxt[x]==x)
            return x;
        return nxt[x] =find(nxt[x]);
    }
    inline void unite(int x,int y){
        nxt[find(y)] = find(x);
    }
};



int main(){
    scanf("%lld", &N);
    UnionFind uf;
    uf.init(N);
    fornum(i,1,N){
        ll u, v;
        scanf("%lld%lld", &u, &v);
        uf.unite(u, v);
    }
    ans = 0;
    fornum(i,0,N){
        if(uf.find(i)==i){
            ++ans;
        }
    }
    if(ans==1){
        printf("Bob");
    }else{
        printf("Alice");
    }
    

    return 0;
}
0