結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー veqccveqcc
提出日時 2020-01-31 22:01:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,009 bytes
コンパイル時間 979 ms
コンパイル使用メモリ 109,392 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-10-17 09:43:30
合計ジャッジ時間 3,563 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
4,348 KB
testcase_09 RE -
testcase_10 AC 2 ms
4,348 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 5 ms
4,348 KB
testcase_18 WA -
testcase_19 AC 11 ms
4,808 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 32 ms
8,768 KB
testcase_24 AC 31 ms
8,768 KB
testcase_25 AC 32 ms
8,768 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;

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

    int n;
    cin >> n;

    vector < vector <int> > edge(n - 1);
    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 = 0;
    int have_one_edge = 0;
    for (int i = 0; i < n - 1; i++) {
        if (edge[i].size() == 0) {
            isolated++;
        } else if (edge[i].size() == 1) {
            have_one_edge++;
        }
    }

    if (isolated >= 2 || (isolated == 1 && have_one_edge)) {
        cout << "Alice" << '\n';
    } else {
        cout << "Bob" << '\n';
    }

    return 0;
}
0