結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
y61mpnl
|
| 提出日時 | 2020-01-31 21:58:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 1,286 bytes |
| コンパイル時間 | 1,704 ms |
| コンパイル使用メモリ | 176,816 KB |
| 実行使用メモリ | 10,112 KB |
| 最終ジャッジ日時 | 2024-09-17 08:08:08 |
| 合計ジャッジ時間 | 2,972 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include<bits/stdc++.h>
using ll = long long;
int main(){
ll n;
scanf("%lld", &n);
std::vector<std::vector<ll>> links(n, std::vector<ll>(0));
for(ll i=1; i<n; i++){
ll a, b;
scanf("%lld %lld", &a, &b);
links[a].push_back(b);
links[b].push_back(a);
}
ll islands = 0;
std::vector<ll> a(n, 1), landsize(0);
for(ll i=0; i<n; i++){
if(!a[i]) continue;
islands++;
ll tmp = 0;
std::queue<ll> que;
que.push(i);
while(!que.empty()){
ll from = que.front(); que.pop();
a[from] = 0;
tmp++;
for(ll to: links[from]){
if(a[to]) que.push(to);
}
}
landsize.push_back(tmp);
}
ll bob = 1;
if(islands==1) puts("Bob");
else if(islands==2){
ll alice = 0;
for(std::vector<ll> l: links) alice |= (l.size()==1);
if(alice) puts("Alice");
else puts("Bob");
}else puts("Alice");
return 0;
}
y61mpnl