結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー VvyLwVvyLw
提出日時 2024-06-20 18:51:53
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 1,954 ms
コンパイル使用メモリ 122,264 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-20 18:51:57
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 4 ms
6,944 KB
testcase_14 AC 4 ms
6,944 KB
testcase_15 AC 4 ms
6,944 KB
testcase_16 AC 4 ms
6,944 KB
testcase_17 AC 4 ms
6,944 KB
testcase_18 AC 9 ms
6,940 KB
testcase_19 AC 8 ms
6,944 KB
testcase_20 AC 12 ms
6,944 KB
testcase_21 AC 19 ms
6,940 KB
testcase_22 AC 23 ms
6,940 KB
testcase_23 AC 24 ms
6,944 KB
testcase_24 AC 23 ms
6,940 KB
testcase_25 AC 24 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/dsu>
#include <ranges>
constexpr auto range = std::views::iota;
int main() {
    std::cin.tie(nullptr) -> sync_with_stdio(false);
    int n;
    std::cin >> n;
    atcoder::dsu uf(n);
    std::vector<int> cnt(n);
    bool gg = true;
    for(const auto i: range(0, n - 1)) {
        int u, v;
        std::cin >> u >> v;
        gg &= !uf.same(u, v);
        uf.merge(u, v);
        cnt[u]++;
        cnt[v]++;
    }
    if(gg) {
        std::cout << "Bob\n";
        std::exit(0);
    }
    if(std::ranges::any_of(cnt, [](const int x) -> bool { return x >= 1 && x != 2; })) {
        std::cout << "Alice\n";
        std::exit(0);
    }
    std::cout << (uf.size(0) == n - 1 || uf.size(1) == n - 1 ? "Bob\n" : "Alice\n");
}
0