結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー pekempeypekempey
提出日時 2020-02-14 10:37:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 764 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 82,700 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-04-16 00:09:40
合計ジャッジ時間 2,995 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 9 ms
5,376 KB
testcase_14 AC 9 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 8 ms
5,376 KB
testcase_18 AC 26 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 44 ms
5,888 KB
testcase_21 AC 70 ms
7,424 KB
testcase_22 AC 88 ms
8,576 KB
testcase_23 AC 98 ms
8,704 KB
testcase_24 AC 92 ms
8,704 KB
testcase_25 AC 103 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

using ll = long long;

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);
    }
    queue<int> q;
    q.push(0);
    vector<bool> visited(N);
    visited[0] = true;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v : G[u]) {
            if (!visited[v]) {
                visited[v] = true;
                q.push(v);
            }
        }
    }
    if (count(visited.begin(), visited.end(), false) == 0) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
}
0