結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー toto6114toto6114
提出日時 2020-02-03 15:39:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,425 bytes
コンパイル時間 1,186 ms
コンパイル使用メモリ 115,128 KB
実行使用メモリ 9,532 KB
最終ジャッジ日時 2023-10-19 02:54:12
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 6 ms
4,348 KB
testcase_16 AC 6 ms
4,348 KB
testcase_17 AC 5 ms
4,348 KB
testcase_18 AC 14 ms
5,396 KB
testcase_19 AC 14 ms
5,384 KB
testcase_20 AC 25 ms
6,452 KB
testcase_21 AC 45 ms
8,060 KB
testcase_22 AC 56 ms
9,224 KB
testcase_23 AC 59 ms
9,528 KB
testcase_24 AC 49 ms
9,532 KB
testcase_25 AC 56 ms
9,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int mod=998244353;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<ll,ll> P;
int par[100005]={},u,v,n,f=1;
int find(int x) {
  if(par[x]==x) {
    return x;
  }
  return par[x]=find(par[x]);
}
bool same(int x,int y) {
  return par[x]==par[y];
}
void unit(int x,int y) {
  x=find(x),y=find(y);
  if(x!=y) {
    par[x]=y;
  }
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  vector<int> G[n]={};
  for(int i=0; i<n; i++) {
    par[i]=i;
  }
  for(int i=0; i<n-1; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
    unit(u,v);
  }
  set<int> s;
  for(int i=0; i<n; i++) {
    s.insert(find(i));
  }
  if(s.size()==1) {
    cout << "Bob" << endl;
  }
  else if(s.size()>=3) {
    cout << "Alice" << endl;
  }
  else {
    for(int i=0; i<n; i++) {
      if(G[i].size()!=0&&G[i].size()!=2) {
        f=0;
      }
    }
    cout << (f?"Bob":"Alice") << endl;
  }
}
0