結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー veqccveqcc
提出日時 2020-01-31 22:12:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,229 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 110,968 KB
実行使用メモリ 8,812 KB
最終ジャッジ日時 2023-10-17 10:03:30
合計ジャッジ時間 2,299 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,408 KB
testcase_01 AC 3 ms
5,408 KB
testcase_02 AC 3 ms
5,408 KB
testcase_03 AC 3 ms
5,408 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 4 ms
5,408 KB
testcase_07 AC 4 ms
5,408 KB
testcase_08 AC 3 ms
5,408 KB
testcase_09 AC 3 ms
5,408 KB
testcase_10 AC 3 ms
5,408 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 7 ms
5,848 KB
testcase_14 AC 6 ms
6,112 KB
testcase_15 AC 7 ms
6,112 KB
testcase_16 AC 6 ms
5,848 KB
testcase_17 WA -
testcase_18 AC 14 ms
6,640 KB
testcase_19 AC 15 ms
7,960 KB
testcase_20 AC 23 ms
7,696 KB
testcase_21 AC 32 ms
7,960 KB
testcase_22 AC 42 ms
8,812 KB
testcase_23 AC 42 ms
8,752 KB
testcase_24 WA -
testcase_25 AC 41 ms
8,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

vector < vector <int> > edge(100005);
vector <bool> visited(100005);

void dfs(int cur) {
    visited[cur] = 1;
    for (int nxt : edge[cur]) {
        if (!visited[nxt]) {
            dfs(nxt);
        }
    }
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    int isolated_count = 0;
    int separated_count = 0;
    for (int i = 0; i < n; i++) {
        if (edge[i].size() == 0) {
            isolated_count++;
        }

        if (!visited[i]) {
            separated_count++;
            dfs(i);
        }
    }

    if (separated_count > 2 || (separated_count == 2 && isolated_count == 0)) {
        cout << "Alice" << '\n';
    } else {
        cout << "Bob" << '\n';
    }

    return 0;
}
0