結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー nakaken88nakaken88
提出日時 2020-02-01 08:04:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 1,720 ms
コンパイル使用メモリ 172,392 KB
実行使用メモリ 10,076 KB
最終ジャッジ日時 2023-10-18 23:45:43
合計ジャッジ時間 3,267 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,260 KB
testcase_01 AC 4 ms
6,260 KB
testcase_02 AC 4 ms
6,260 KB
testcase_03 AC 4 ms
6,260 KB
testcase_04 AC 4 ms
6,260 KB
testcase_05 AC 4 ms
6,260 KB
testcase_06 AC 4 ms
6,260 KB
testcase_07 AC 4 ms
6,260 KB
testcase_08 AC 5 ms
6,260 KB
testcase_09 AC 4 ms
6,260 KB
testcase_10 WA -
testcase_11 AC 4 ms
6,260 KB
testcase_12 AC 4 ms
6,260 KB
testcase_13 AC 8 ms
6,644 KB
testcase_14 AC 8 ms
6,908 KB
testcase_15 AC 8 ms
6,908 KB
testcase_16 AC 7 ms
6,644 KB
testcase_17 AC 8 ms
6,908 KB
testcase_18 AC 16 ms
7,436 KB
testcase_19 WA -
testcase_20 AC 28 ms
8,228 KB
testcase_21 AC 47 ms
8,756 KB
testcase_22 AC 69 ms
9,284 KB
testcase_23 AC 61 ms
10,076 KB
testcase_24 AC 58 ms
10,076 KB
testcase_25 AC 70 ms
10,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<vector<ll>> G(100005);
vector<ll> used(100005, 0);

void dfs(int c) {
  for (ll n: G[c]) {
    if (used[n]) continue;
    used[n] = 1;
    dfs(n);
  }
}

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

  int N; cin >> N;

  for (ll i = 0; i < N - 1; i++) {
    ll a, b; cin >> a >> b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    if (!used[i]) {
      cnt++;
      used[i] = 1;
      dfs(i);
    }
  }
  
  string ans;
  if (cnt > 1) ans = "Alice";
  else ans = "Bob";
  cout << ans << '\n';
  return 0;
}
0