結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー ngtkanangtkana
提出日時 2019-09-23 20:31:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,173 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 210,552 KB
実行使用メモリ 9,608 KB
最終ジャッジ日時 2023-10-19 08:16:00
合計ジャッジ時間 3,423 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 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 6 ms
4,348 KB
testcase_16 AC 6 ms
4,348 KB
testcase_17 AC 5 ms
4,348 KB
testcase_18 AC 13 ms
5,472 KB
testcase_19 AC 12 ms
5,452 KB
testcase_20 AC 19 ms
6,528 KB
testcase_21 AC 31 ms
8,096 KB
testcase_22 AC 42 ms
9,292 KB
testcase_23 AC 48 ms
9,608 KB
testcase_24 AC 44 ms
9,608 KB
testcase_25 AC 47 ms
9,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
void alice() {
  std::cout << "Alice" << std::endl;
  exit(0);
}
void bob() {
  std::cout << "Bob" << std::endl;
  exit(0);
}
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< std::vector< int > > graph(n);
  loop(n - 1) {
    int u, v; std::cin >> u >> v;
    graph.at(u).emplace_back(v);
    graph.at(v).emplace_back(u);
  }
  auto root = -1;
  rep(i, 0, n) {
    if (!graph.at(i).empty())
      { root = i; }
  }
  std::vector< int > ckd(n, false);
  std::queue< int > que;
  que.emplace(root);
  while(!que.empty()) {
    auto crr = que.front(); que.pop();
    for (auto nxt : graph.at(crr)) {
      if (ckd.at(nxt)) continue;
      ckd.at(nxt) = true;
      que.emplace(nxt);
    }
  }
  auto cmp = std::accumulate(all(ckd), 0);
  if (cmp == n) bob();
  if (cmp <= n - 2) alice();
  for (auto const & v : graph) {
    if (!v.empty() && v.size() != 2u) alice();
  }
  bob();
  return 0;
}
0