結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー recososorecososo
提出日時 2020-02-06 12:33:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 2,613 ms
コンパイル使用メモリ 174,468 KB
実行使用メモリ 9,000 KB
最終ジャッジ日時 2023-10-25 22:27:09
合計ジャッジ時間 3,016 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,472 KB
testcase_01 AC 3 ms
5,472 KB
testcase_02 AC 3 ms
5,472 KB
testcase_03 AC 3 ms
5,472 KB
testcase_04 AC 3 ms
5,472 KB
testcase_05 AC 3 ms
5,472 KB
testcase_06 AC 4 ms
5,472 KB
testcase_07 AC 3 ms
5,472 KB
testcase_08 AC 4 ms
5,472 KB
testcase_09 AC 3 ms
5,472 KB
testcase_10 WA -
testcase_11 AC 3 ms
5,472 KB
testcase_12 AC 4 ms
5,472 KB
testcase_13 AC 10 ms
5,912 KB
testcase_14 AC 9 ms
5,912 KB
testcase_15 AC 10 ms
5,912 KB
testcase_16 AC 10 ms
5,912 KB
testcase_17 AC 9 ms
5,912 KB
testcase_18 AC 24 ms
6,704 KB
testcase_19 WA -
testcase_20 AC 36 ms
7,232 KB
testcase_21 AC 54 ms
8,024 KB
testcase_22 AC 69 ms
8,772 KB
testcase_23 AC 77 ms
9,000 KB
testcase_24 AC 77 ms
9,000 KB
testcase_25 AC 79 ms
9,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int nmax=100005;
vector<vector<int>> g(nmax);
bool vis[nmax];
void bfs(int s){
    stack<int> st;
    vis[s]=true;
    st.push(s);
    while(!st.empty()){
        int p=st.top();
        st.pop();
        for(auto x:g[p]){
            if(!vis[x]){
                vis[x]=true;
                st.push(x);
            }
        }
    }
}
int main(){
    int n;cin >> n;
    for(int i=0;i<n-1;i++){
        int a,b;cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bfs(0);
    for(int i=0;i<n;i++){
        if(!vis[i]){
            cout << "Alice" << endl;
            return 0;
        }
    }
    cout << "Bob" << endl;
}
0