結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー recososo
提出日時 2020-02-06 12:33:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 173,844 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-09-25 06:42:56
合計ジャッジ時間 3,166 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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