#include #include #include #include using namespace std; vector g[100000]; int dp[100000]; int ans[100000]; int mex(const map &mp) { int res = 0; while (mp.count(res)) res++; return res; } void dfs(int u, int p) { map mp; for (int v : g[u]) if (v != p) { dfs(v, u); mp[dp[v]]++; } dp[u] = mex(mp); } void dfs2(int u, int p) { map mp; for (int v : g[u]) { mp[dp[v]]++; } ans[u] = mex(mp); for (int v : g[u]) if (v != p) { if (mp[dp[v]] == 1 && dp[v] < ans[u]) { dp[u] = dp[v]; } dfs2(v, u); } } int main() { int n; cin >> n; for (int i = 0; i < n - 1; i++) { int u, v; cin >> u >> v; u--; v--; g[u].push_back(v); g[v].push_back(u); } dfs(0, -1); dfs2(0, -1); cout << count(ans, ans + n, 0) << endl; for (int i = 0; i < n; i++) { if (ans[i] == 0) { cout << i + 1 << endl; } } }