結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー kagasankagasan
提出日時 2020-03-09 18:31:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,409 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 172,496 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-26 04:14:00
合計ジャッジ時間 4,485 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,888 KB
testcase_01 AC 4 ms
6,144 KB
testcase_02 AC 2 ms
6,016 KB
testcase_03 AC 3 ms
6,016 KB
testcase_04 AC 3 ms
6,144 KB
testcase_05 AC 3 ms
6,144 KB
testcase_06 AC 4 ms
6,144 KB
testcase_07 AC 3 ms
6,016 KB
testcase_08 AC 3 ms
6,016 KB
testcase_09 AC 3 ms
5,888 KB
testcase_10 WA -
testcase_11 AC 3 ms
6,144 KB
testcase_12 AC 3 ms
6,144 KB
testcase_13 AC 9 ms
6,400 KB
testcase_14 AC 10 ms
6,528 KB
testcase_15 AC 9 ms
6,528 KB
testcase_16 AC 11 ms
6,528 KB
testcase_17 AC 9 ms
6,400 KB
testcase_18 AC 27 ms
7,296 KB
testcase_19 WA -
testcase_20 AC 41 ms
7,788 KB
testcase_21 AC 66 ms
8,960 KB
testcase_22 AC 84 ms
9,600 KB
testcase_23 AC 89 ms
10,368 KB
testcase_24 AC 89 ms
10,368 KB
testcase_25 AC 90 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

V path[101010];
ll flg[101010];
ll cnt = 0;
int main(){

    ll N;
    cin >> N;
    rep(i, N - 1){
        ll a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    rep(i, N)if(flg[i] == 0){
        cnt++;
        flg[i] = cnt;
        queue<ll>Q;
        Q.push(i);
        while(!Q.empty()){
            ll idx = Q.front();
            Q.pop();
            for(auto to : path[idx])if(flg[to] == 0){
                flg[to] = cnt;
                Q.push(to);
            }
        }
    }    
    if(cnt == 1)cout << "Bob" << endl;
    else cout << "Alice" << endl;
    return 0;
}
0