結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー nejinejinejineji
提出日時 2020-01-31 21:50:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 1,690 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 72,284 KB
実行使用メモリ 10,156 KB
最終ジャッジ日時 2023-10-17 09:23:37
合計ジャッジ時間 2,240 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 2 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 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 9 ms
4,348 KB
testcase_15 AC 9 ms
4,348 KB
testcase_16 AC 9 ms
4,348 KB
testcase_17 AC 9 ms
4,648 KB
testcase_18 AC 26 ms
5,404 KB
testcase_19 AC 29 ms
6,988 KB
testcase_20 AC 46 ms
6,988 KB
testcase_21 AC 77 ms
8,044 KB
testcase_22 AC 103 ms
9,364 KB
testcase_23 AC 100 ms
10,156 KB
testcase_24 AC 97 ms
10,156 KB
testcase_25 AC 102 ms
10,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

void dfs(ll n,ll cur, vll& color, vvll& g){
        if(color[cur] == 1){
                return;
        }else{
                color[cur] = 1;
                for(auto x: g[cur]){
                        if(color[x] == 0){
                                dfs(n, x, color, g);
                        }
                }
        }
}

int main(){
        ll n;
        cin >> n;
        vvll g(n);
        REP(i,1,n-1){
                ll u,v;
                cin >> u >> v;
                g[u].push_back(v);
                g[v].push_back(u);
        }
        vll color(n,0);
        ll conn = 0;
        REP(i,0,n-1){
                if(color[i] == 0){
                        dfs(n,i,color, g);
                        conn++;
                }
        }
        if(conn == 1){
                cout << "Bob" << endl;
                return 0;
        }else if(conn == 2){
                REP(i,0,n-1){
                        if(g[i].size()==1 || g[i].size() > 2){
                                cout << "Alice" << endl;
                                return 0;
                        }
                }
                cout << "Bob" << endl;
        }else{
                cout << "Alice" << endl;
        }

}
0