結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー 👑 zeronosu77108zeronosu77108
提出日時 2020-01-31 22:34:58
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,264 bytes
コンパイル時間 1,081 ms
コンパイル使用メモリ 141,228 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-05-07 20:21:05
合計ジャッジ時間 2,178 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 12 ms
5,376 KB
testcase_19 AC 13 ms
6,272 KB
testcase_20 AC 17 ms
6,272 KB
testcase_21 AC 25 ms
7,296 KB
testcase_22 AC 33 ms
8,320 KB
testcase_23 AC 39 ms
8,612 KB
testcase_24 WA -
testcase_25 AC 41 ms
8,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

void dfs(int u, vector<vector<int>>& g, vector<bool>& visited) {
    if (visited[u]) return;
    visited[u] = true;
    for(const auto& v : g[u]) {
        dfs(v, g, visited);
    }
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<bool> visited(n,false);
    dfs(0, g, visited);
    bool ans = all_of(visited.begin(), visited.end(), [](bool x){return x;});

    {
        int cnt = 0;
        for (auto v : visited) {
            if (!v) cnt++;
        }
        ans = ans || (cnt == 1);
    }

    cout << (ans? "Bob" : "Alice") << endl;
}
0