結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
|
提出日時 | 2020-01-31 21:54:32 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,502 bytes |
コンパイル時間 | 1,388 ms |
コンパイル使用メモリ | 143,584 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-11-30 16:18:51 |
合計ジャッジ時間 | 2,533 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <utility> #include <map> #include <algorithm> #include <queue> #include <cmath> #include <numeric> #include <set> using namespace std; struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa; template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;} #define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;} using int64 = long long; void dfs(int64 u, int64 p, const vector<vector<int64>>& g, vector<bool>& visited, vector<int64>& path) { if (visited[u]) return; visited[u] = true; for(const auto& v : g[u]) { if (v == p) continue; path[v]++; dfs(v, u, g, visited, path); } } int main() { int64 n; cin >> n; vector<vector<int64>> g(n); if (n == 2) { cout << "Bob" << endl; return 0; } for (int i = 0; i < n - 1; i++) { int64 u, v; cin >> u >> v; g[u].push_back(v); g[v].push_back(u); } vector<bool> visited(n,false); vector<int64> path(n,0); path[0]++; dfs(0, -1, g, visited, path); map<int,int> mp; for (const auto& v : path) { mp[v]++; } auto c = [](int x) {return x;}; bool ans = all_of(visited.begin(), visited.end(), c); if (mp[0] == 1 && mp[1] <= 0) ans = true; cout << (ans? "Bob" : "Alice") << endl; }