結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー msm1993msm1993
提出日時 2020-04-02 17:21:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,510 bytes
コンパイル時間 1,670 ms
コンパイル使用メモリ 172,344 KB
実行使用メモリ 9,104 KB
最終ジャッジ日時 2023-09-11 00:33:18
合計ジャッジ時間 3,923 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,752 KB
testcase_01 AC 4 ms
5,460 KB
testcase_02 AC 3 ms
5,624 KB
testcase_03 AC 4 ms
5,784 KB
testcase_04 AC 4 ms
5,616 KB
testcase_05 AC 3 ms
5,684 KB
testcase_06 AC 3 ms
5,884 KB
testcase_07 AC 4 ms
5,628 KB
testcase_08 AC 3 ms
5,504 KB
testcase_09 AC 3 ms
5,688 KB
testcase_10 AC 4 ms
5,604 KB
testcase_11 AC 4 ms
5,696 KB
testcase_12 AC 4 ms
5,560 KB
testcase_13 AC 11 ms
6,180 KB
testcase_14 AC 11 ms
6,148 KB
testcase_15 AC 10 ms
6,248 KB
testcase_16 AC 10 ms
5,884 KB
testcase_17 AC 10 ms
6,300 KB
testcase_18 AC 25 ms
6,784 KB
testcase_19 AC 29 ms
7,312 KB
testcase_20 AC 46 ms
7,392 KB
testcase_21 AC 76 ms
8,104 KB
testcase_22 AC 100 ms
8,964 KB
testcase_23 AC 93 ms
9,016 KB
testcase_24 AC 88 ms
9,104 KB
testcase_25 AC 95 ms
8,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------
int N;
vector<vector<int>> G(100005);
vector<int> dist(100005,-1);
void dfs(int v){
  for(int nv:G[v]){
    if(dist[nv] != -1) continue;
    dist[nv] = 0;
    dfs(nv);
  }
  return;
}

int main(){
  cin >> N;
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int cnt = 0;
  for(int i=0; i<N; i++){
    if(dist[i] == -1){
      cnt++;
      dfs(i);
    }
  }
  if(cnt == 1){
    cout << "Bob" << endl;
  }else if(cnt == 2){
    rep(i,N){
      if(G[i].size() == 1){
        cout << "Alice" << endl;
        return 0;
      }
    }
    cout << "Bob" << endl;
  }else{
    cout << "Alice" << endl;
  }
  return 0;
}
0