結果
| 問題 |
No.2800 Game on Tree Inverse
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2024-06-28 22:37:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,411 bytes |
| コンパイル時間 | 2,395 ms |
| コンパイル使用メモリ | 199,944 KB |
| 最終ジャッジ日時 | 2025-02-22 01:16:36 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 WA * 59 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;
vector<int> G[MAX];
int sz[MAX];
void mk(int u,int p){
sz[u]=1;
for(int to:G[u]){
if(to==p) continue;
mk(to,u);
sz[u]+=sz[to];
}
}
vector<int> ans;
int X;
void solve(int u,int p){
int sv=X;
X^=sz[u];
for(int to:G[u]){
if(to==p) continue;
X^=sz[to];
}
if(X==0) ans.push_back(u);
for(int to:G[u]){
if(to==p) continue;
solve(to,u);
}
X=sv;
}
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int N;cin>>N;
for(int i=0;i<N-1;i++){
int a,b;cin>>a>>b;a--;b--;
G[a].push_back(b);
G[b].push_back(a);
}
mk(0,-1);
X=N;
solve(0,-1);
if(si(ans)){
cout<<"Alice\n";
cout<<si(ans)<<"\n";
sort(all(ans));
for(int x:ans) cout<<x+1<<" ";
cout<<"\n";
}else{
cout<<"Bob\n";
}
}
Rubikun