結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,380 KB
testcase_01 AC 4 ms
5,380 KB
testcase_02 AC 4 ms
5,380 KB
testcase_03 AC 3 ms
5,380 KB
testcase_04 AC 4 ms
5,380 KB
testcase_05 AC 4 ms
5,380 KB
testcase_06 AC 4 ms
5,380 KB
testcase_07 AC 4 ms
5,380 KB
testcase_08 AC 4 ms
5,380 KB
testcase_09 AC 4 ms
5,380 KB
testcase_10 WA -
testcase_11 AC 4 ms
5,380 KB
testcase_12 AC 3 ms
5,380 KB
testcase_13 AC 7 ms
5,812 KB
testcase_14 AC 7 ms
6,076 KB
testcase_15 AC 7 ms
6,076 KB
testcase_16 AC 7 ms
5,812 KB
testcase_17 AC 7 ms
6,340 KB
testcase_18 AC 15 ms
6,604 KB
testcase_19 WA -
testcase_20 AC 24 ms
7,660 KB
testcase_21 AC 40 ms
7,924 KB
testcase_22 AC 54 ms
8,776 KB
testcase_23 AC 52 ms
8,716 KB
testcase_24 AC 53 ms
8,716 KB
testcase_25 AC 56 ms
8,716 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 separated_count = 0;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            separated_count++;
            dfs(i);
        }
    }

    if (separated_count > 1) {
        cout << "Alice" << '\n';
    } else {
        cout << "Bob" << '\n';
    }

    return 0;
}
0