結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
|
提出日時 | 2021-09-30 22:35:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 999 bytes |
コンパイル時間 | 2,248 ms |
コンパイル使用メモリ | 198,072 KB |
最終ジャッジ日時 | 2025-01-24 18:43:45 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; vector <int> adj[100005]; int n,a,b; bool visited[100005]; int cnt = 0; int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for(int i=0;i<n-1;i++) { cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } memset(visited,false,sizeof(visited)); vector <int> vec; for(int i=0;i<n;i++) { int MIN = 1e9; if(visited[i]==false) { queue <int> que; cnt++; que.push(i); visited[i] = true; cout << i << '\n'; while(!que.empty()) { int now = que.front(); que.pop(); MIN = min(MIN,(int)(adj[now].size())); for(auto next : adj[now]) { if(visited[next]==false) { visited[next] = true; que.push(next); } } } } if(MIN==1) { vec.push_back(MIN); } } if(cnt==1) cout << "Bob" << '\n'; else if(cnt==2) { if(vec.size()==0) cout << "Bob" << '\n'; else cout << "Alice" << '\n'; } else { cout << "Alice" << '\n'; } return 0; }