結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー bonKotsubonKotsu
提出日時 2021-06-25 00:06:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 1,589 ms
コンパイル使用メモリ 168,120 KB
実行使用メモリ 9,300 KB
最終ジャッジ日時 2023-09-07 13:30:41
合計ジャッジ時間 3,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,716 KB
testcase_01 AC 3 ms
5,800 KB
testcase_02 AC 3 ms
5,868 KB
testcase_03 AC 3 ms
5,868 KB
testcase_04 AC 3 ms
5,760 KB
testcase_05 AC 3 ms
5,732 KB
testcase_06 AC 3 ms
5,924 KB
testcase_07 AC 3 ms
5,760 KB
testcase_08 AC 3 ms
5,828 KB
testcase_09 AC 3 ms
5,868 KB
testcase_10 AC 4 ms
5,768 KB
testcase_11 AC 3 ms
5,708 KB
testcase_12 WA -
testcase_13 AC 9 ms
6,084 KB
testcase_14 AC 9 ms
6,044 KB
testcase_15 AC 9 ms
6,188 KB
testcase_16 AC 9 ms
6,200 KB
testcase_17 WA -
testcase_18 AC 24 ms
6,776 KB
testcase_19 AC 23 ms
8,128 KB
testcase_20 AC 35 ms
7,804 KB
testcase_21 AC 52 ms
8,128 KB
testcase_22 AC 65 ms
8,816 KB
testcase_23 AC 77 ms
9,028 KB
testcase_24 AC 79 ms
9,300 KB
testcase_25 AC 78 ms
9,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>

vector<int> G[100005];
bool seen[100005];
bool loopflag = false;

void dfs(int v, int p) {
  if (seen[v]) {
    if (v == 0) loopflag = true;
    return;
  }
  seen[v] = true;

  for (int nv : G[v]) {
    if (nv == p) continue;
    dfs(nv, v);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n-1) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(0, 0);
  bool flag = true;
  string ans = "Alice";
  if (loopflag) {
    int cnt = 0;
    rep(i,n) {
      if (seen[i]) cnt++;
    }
    if (cnt == n-1) ans = "Bob";
  } else {
    rep(i,n) {
      if (!seen[i]) flag = false;
    }
    if (flag) ans = "Bob";
  }
  cout << ans << endl;



}
0