結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,664 KB
testcase_01 AC 3 ms
5,668 KB
testcase_02 AC 3 ms
5,676 KB
testcase_03 AC 4 ms
5,812 KB
testcase_04 AC 3 ms
5,676 KB
testcase_05 AC 3 ms
5,676 KB
testcase_06 AC 3 ms
5,724 KB
testcase_07 AC 3 ms
5,712 KB
testcase_08 AC 3 ms
5,792 KB
testcase_09 AC 3 ms
5,680 KB
testcase_10 WA -
testcase_11 AC 3 ms
5,680 KB
testcase_12 AC 3 ms
5,964 KB
testcase_13 AC 10 ms
6,076 KB
testcase_14 AC 10 ms
5,996 KB
testcase_15 AC 11 ms
6,168 KB
testcase_16 AC 10 ms
6,104 KB
testcase_17 AC 10 ms
6,564 KB
testcase_18 AC 25 ms
6,864 KB
testcase_19 WA -
testcase_20 AC 40 ms
8,000 KB
testcase_21 AC 62 ms
8,668 KB
testcase_22 AC 80 ms
9,276 KB
testcase_23 AC 92 ms
9,376 KB
testcase_24 AC 88 ms
9,320 KB
testcase_25 AC 91 ms
9,328 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>

int n;
const int INF = 1001001001;
vector<int> G[100005];
int dist[100005];
bool seen[100005];
bool loopflag = false;

void dfs(int v, int p) {
  if (seen[v]) {
    if (v == 0) {
      if (dist[p] == n-1) loopflag = true;
    }
    return;
  }
  seen[v] = true;
  for (int nv : G[v]) {
    if (nv == p) continue;
    dfs(nv, v);
  }
}

int main() {
  cin >> n;
  rep(i,n-1) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  rep(i,n) dist[i] = INF;
  dist[0] = 0;
  dfs(0,0);

  string ans = "Alice";
  if (loopflag) ans = "Bob";
  else {
    bool flag = true;
    rep(i,n) {
      if (!seen[i]) flag = false;
    }
    if (flag) ans = "Bob";
  }
  cout << ans << endl;



}
0