#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long typedef vector VI; typedef pair pii; typedef vector VP; typedef vector VS; typedef priority_queue PQ; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i, greater > q2; int N; vectorG; bool dp[200010]; bool ans[200010]; int cnt[200010]; bool dfs(int now, int pa) { dp[now] = true; fore(to, G[now]) { if (to == pa)continue; if (dfs(to, now)) { dp[now] = false; cnt[now]++; } } return dp[now]; } void dfs1(int now, int pa) { //cout << now << " " << pa << endl; ans[now] = 1; fore(to, G[now])if (dp[to])ans[now] = false; VI wins; fore(to, G[now])if (dp[to]) { //cout << now << " " << to << endl; wins.push_back(to); } if (wins.size() == 0) { dp[now] = 1; fore(to, G[now])if (to != pa)dfs1(to, now); return; } else if (1 < wins.size()) { dp[now] = 0; fore(to, G[now])if (to != pa)dfs1(to, now); return; } else { fore(to, G[now])if (to != pa) { if (wins[0] == to)dp[now] = 1; else dp[now] = 0; dfs1(to, now); } return; } } signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; G.resize(N); REP(i, N - 1) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } dfs(0,-1); dfs1(0, -1); VI a; REP(i, N) { if (ans[i])a.push_back(i + 1); } cout << a.size() << endl; REP(i, a.size())cout << a[i] << endl; return 0; }