結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー hig98ingrohig98ingro
提出日時 2020-01-31 21:55:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,180 bytes
コンパイル時間 1,557 ms
コンパイル使用メモリ 170,776 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 09:35:00
合計ジャッジ時間 2,774 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 8 ms
4,348 KB
testcase_19 AC 9 ms
4,348 KB
testcase_20 AC 12 ms
4,348 KB
testcase_21 AC 17 ms
4,348 KB
testcase_22 AC 21 ms
4,348 KB
testcase_23 AC 27 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 27 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);
    }
    ll a = 0;
    ll b = -1;
    fornum(i,0,N){
        if(uf.find(i)==i){
            a++;
        }else{
            if(b==uf.find(i)||b==-1){
                b = uf.find(i);
            }else{
                break;
            }
        }
    }
    //printf("%lld %lld %lld\n",a,b, i);
    if(i==N&&a<=2){
        printf("Bob");
    }else{
        printf("Alice");
    }
    

    return 0;
}
0