結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー kappybarkappybar
提出日時 2020-03-25 09:21:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 2,642 ms
コンパイル使用メモリ 171,084 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-08-30 09:26:51
合計ジャッジ時間 5,226 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,252 KB
testcase_01 AC 4 ms
5,452 KB
testcase_02 AC 3 ms
5,416 KB
testcase_03 AC 4 ms
5,348 KB
testcase_04 AC 4 ms
5,196 KB
testcase_05 AC 4 ms
5,200 KB
testcase_06 AC 3 ms
5,316 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 2 ms
5,272 KB
testcase_09 AC 4 ms
5,348 KB
testcase_10 AC 4 ms
5,424 KB
testcase_11 AC 4 ms
5,340 KB
testcase_12 AC 4 ms
5,396 KB
testcase_13 AC 10 ms
5,624 KB
testcase_14 AC 10 ms
5,892 KB
testcase_15 AC 10 ms
5,944 KB
testcase_16 AC 11 ms
5,796 KB
testcase_17 AC 10 ms
6,488 KB
testcase_18 AC 25 ms
6,164 KB
testcase_19 AC 27 ms
8,440 KB
testcase_20 AC 41 ms
7,716 KB
testcase_21 AC 69 ms
7,788 KB
testcase_22 AC 90 ms
8,364 KB
testcase_23 AC 95 ms
8,704 KB
testcase_24 AC 87 ms
8,604 KB
testcase_25 AC 88 ms
8,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

int n = 100005;
vector<vector<int>> graph(n,vector<int>());
vector<bool> visited(n,false);

void dfs(int i,int before){
    visited[i] = true;
    for(int p:graph[i]){
        if(p == before) continue;
        if(!visited[p]) dfs(p,i);
    }
}


int main() {
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int cnt = 0;
    rep(i,n){
        if(!visited[i]){
            dfs(i,-1);
            cnt ++;
        }
    }

    if(cnt == 1){
        cout << "Bob" << endl;
        return 0;
    }
    else if(cnt >= 3){
        cout << "Alice" << endl;
        return 0;
    }
    else{
        rep(i,n){
            if(graph[i].size() == 1){
                cout << "Alice" << endl;
                return 0;
            }
        }
    }

    cout << "Bob" <<endl;
    return 0;

    
}
0