結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
|
| 提出日時 | 2020-02-01 08:28:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 819 bytes |
| コンパイル時間 | 1,405 ms |
| コンパイル使用メモリ | 171,532 KB |
| 実行使用メモリ | 9,984 KB |
| 最終ジャッジ日時 | 2024-09-18 19:43:07 |
| 合計ジャッジ時間 | 2,480 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<ll>> G(100005);
vector<ll> used(100005, 0);
void dfs(int c) {
for (ll n: G[c]) {
if (used[n]) continue;
used[n] = 1;
dfs(n);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N; cin >> N;
for (ll i = 0; i < N - 1; i++) {
ll a, b; cin >> a >> b;
G[a].emplace_back(b);
G[b].emplace_back(a);
}
ll cnt = 0;
for (int i = 0; i < N; i++) {
if (!used[i]) {
used[i] = 1;
cnt++;
dfs(i);
}
}
string ans;
if (cnt > 2) ans = "Alice";
else if (cnt == 1) ans = "Bob";
else {
ans = "Bob";
for (int i = 0; i < N; i++) {
if (G[i].size() != 0 && G[i].size() != 2) {
ans = "Alice";
}
}
}
cout << ans << '\n';
return 0;
}