結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー RyumaRyamaRyumaRyama
提出日時 2020-01-31 22:08:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 753 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 8,852 KB
最終ジャッジ日時 2023-10-17 09:58:05
合計ジャッジ時間 2,301 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 9 ms
4,348 KB
testcase_15 AC 9 ms
4,348 KB
testcase_16 AC 9 ms
4,348 KB
testcase_17 AC 9 ms
4,564 KB
testcase_18 AC 25 ms
4,892 KB
testcase_19 WA -
testcase_20 AC 45 ms
6,740 KB
testcase_21 AC 72 ms
7,532 KB
testcase_22 AC 101 ms
8,588 KB
testcase_23 AC 100 ms
8,852 KB
testcase_24 AC 96 ms
8,852 KB
testcase_25 AC 102 ms
8,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

void dfs(vector<bool>& checked, vector<vector<int>>& path, int island) {
    checked[island] = true;
    for (auto i : path[island]) {
        if (!checked[i]) dfs(checked, path, i);
    }
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> path(n, vector<int>());
    vector<bool> checked(n, false);
    for (int i=0; i<n-1; i++) {
        int u, v;
        cin >> u >> v;
        path[u].push_back(v);
        path[v].push_back(u);
    }

    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (!checked[i]) {
            cnt++;
            dfs(checked, path, i);
        }
    }

    if (cnt >= 2)
        cout << "Alice" << endl;
    else
        cout << "Bob" << endl;
}
0