結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
soto800
|
| 提出日時 | 2020-01-31 22:08:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 251 ms / 2,000 ms |
| コード長 | 1,079 bytes |
| コンパイル時間 | 1,827 ms |
| コンパイル使用メモリ | 177,484 KB |
| 実行使用メモリ | 16,512 KB |
| 最終ジャッジ日時 | 2024-09-17 08:25:23 |
| 合計ジャッジ時間 | 3,902 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
map<lli,vector<lli>> d;
lli branch[100100];
lli data[100100];
bool allTwo;
void dfs(lli from){
if(data[from])return;
if(branch[from]<2){
allTwo=false;
}
data[from]=1;
for(auto e:d[from]){
dfs(e);
}
}
signed main(){
lli n;
cin>>n;
lli two=0;
lli one=0;
lli zero;
REP(i,0,n-1){
lli u,v;
cin>>u>>v;
d[u].push_back(v);
d[v].push_back(u);
branch[u]++;
branch[v]++;
}
REP(i,0,n){
allTwo=true;
if(data[i])continue;
if(branch[i]==0){
two++;
continue;
}
dfs(i);
if(allTwo)two++;
else one++;
}
if(DEBUG)cout<<"one="<<one<<" two="<<two<<endl;
if(one==0){
if(two<=2)cout<<"Bob"<<endl;
else cout<<"Alice"<<endl;
}
else if(one==1){
if(two>0)cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
}
else cout<<"Alice"<<endl;
return 0;
}
soto800