結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー nakaken88
提出日時 2020-02-01 08:04:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 173,204 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-09-18 19:42:54
合計ジャッジ時間 2,450 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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