結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
trineutron
|
| 提出日時 | 2020-02-04 14:44:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,066 bytes |
| コンパイル時間 | 1,655 ms |
| コンパイル使用メモリ | 173,160 KB |
| 実行使用メモリ | 14,016 KB |
| 最終ジャッジ日時 | 2024-09-21 07:22:19 |
| 合計ジャッジ時間 | 5,624 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 TLE * 1 -- * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool dfs(const vector<vector<int>> &to, vector<bool> &isvisited, int index, int prev) {
for (int next : to.at(index)) {
if (next == prev) continue;
if (isvisited.at(next)) {
int period = 0;
for (auto x : isvisited) {
if (x) period++;
}
if (period != isvisited.size() - 1) {
return false;
} else {
continue;
}
}
isvisited.at(next) = true;
if (dfs(to, isvisited, next, index) == false) return false;
}
return true;
}
int main() {
int n;
cin >> n;
vector<vector<int>> to(n);
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
to.at(u).push_back(v);
to.at(v).push_back(u);
}
for (int i = 0; i < n; i++) {
vector<bool> isvisited(n);
if (!dfs(to, isvisited, i, -1)) {
cout << "Alice" << endl;
return 0;
}
}
cout << "Bob" << endl;
}
trineutron