結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー hiro71687khiro71687k
提出日時 2023-02-28 02:02:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,301 bytes
コンパイル時間 5,308 ms
コンパイル使用メモリ 261,632 KB
実行使用メモリ 7,164 KB
最終ジャッジ日時 2023-10-13 09:51:06
合計ジャッジ時間 7,578 ms
ジャッジサーバーID
(参考情報)
judge13 / 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 1 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 7 ms
4,348 KB
testcase_14 AC 7 ms
4,352 KB
testcase_15 AC 7 ms
4,352 KB
testcase_16 AC 7 ms
4,348 KB
testcase_17 AC 7 ms
4,352 KB
testcase_18 AC 19 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 31 ms
4,864 KB
testcase_21 AC 48 ms
6,108 KB
testcase_22 AC 60 ms
6,792 KB
testcase_23 AC 63 ms
7,164 KB
testcase_24 AC 62 ms
7,076 KB
testcase_25 AC 62 ms
7,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.14159265359;
ll inf=10010010010010010;
ll mod=998244353;
struct unionfind
{
    vector<ll>par,siz;
    unionfind(ll n): par(n,-1),siz(n,1){}
    ll root(ll x){
        if (par[x]==-1)
        {
            return x;
        }else{
            return par[x]=root(par[x]);
        }
    }
    bool issame(ll x,ll y){
        return root(x)==root(y);
    }
    bool unite(ll x,ll y){
        x=root(x);
        y=root(y);
        if (x==y)
        {
            return false;
        }
        if (siz[x]<siz[y])
        {
            swap(x,y);
        }
        par[y]=x;
        siz[x]+=siz[y];
        return true;
    }
    ll size(ll x){
        return siz[root(x)];
    }
};
int main(){
    ll n;
    cin >> n;
    unionfind uf(n);
    vector<ll>u(n-1),v(n-1);
    for (ll i = 0; i < n-1; i++)
    {
        cin >> u[i] >> v[i];
        uf.unite(u[i],v[i]);
    }
    ll ans=0;
    vector<ll>memo(n,0);
    for (ll i = 0; i < n; i++)
    {
        if (memo[uf.root(i)]==0)
        {
            ans+=1;
        }
        memo[uf.root(i)]+=1;
    }
    if (ans==1)
    {
        cout << "Bob" << endl;
    }else{
        cout << "Alice" << endl;
    }
}
0