// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip const bool DEBUG = 1; /// --- .lumrc Template {{{ /// #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using P = tuple; using P3 = tuple; using VI = vector; using VL = vector; using VP = vector

; using VS = vector; #define omajinai ios::sync_with_stdio(false);cin.tie(0) #define FOR(i,a,b) for(int i=int(a);i=int(a);--i) #define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i) #define RREP(i,n) RFOR(i,0,n) #define RREPI(i,n) RFORI(i,0,n) #define ALL(a) (a).begin(),(a).end() #define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end()) #define PB push_back #define EACH(i,c) REP(i,(c).size()) #define REACH(i,c) RREP(i,(c).size()) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort(ALL(c)) #define BR cout<<"\n"; #define dump(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)<<"\n"; #define dump2(x,y) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\ <<" , "<<#y<<"="<<(y)<<"\n"; #define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<<"] "<<#x<<"="<<(x)\ <<" , "<<#y<<"="<<(y)\ <<" , "<<#z<<"="<<(z)<<"\n"; #define SAY(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<(x)<<"\n"; #define YES(x) cout<<((x)?"YES":"NO")<<"\n"; #define Yes(x) cout<<((x)?"Yes":"No")<<"\n"; #define yes(x) cout<<((x)?"yes":"no")<<"\n"; inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;} inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;} inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;} inline int int_in(){int n;cin>>n;return n;} inline ll ll_in(){ll n;cin>>n;return n;} inline string string_in(){string n;cin>>n;return n;} #define oini omajinai_int_in() #define oinl omajinai_ll_in() #define oins omajinai_string_in() #define ini int_in() #define inl ll_in() #define ins string_in() #define isInside(y,x) (0<=(y)&&(y)(x)) #define se(x) (get<1>(x)) #define th(x) (get<2>(x)) #define fo(x) (get<3>(x)) #define fif(x) (get<4>(x)) template ostream &operator<<(ostream &o, const vector &v) { o << '['; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]"; return o; } template inline void smax(T &a, T b) { a = a > b ? a : b; } template inline void smin(T &a, T b) { a = a < b ? a : b; } /// }}}--- /// constexpr int INF = 1e9+1; constexpr ll LINF = 1e18+1; constexpr int MOD = 1e9+7; const int N = 1e5; VI g[N]; unordered_map dp[N]; // メモ化再帰 // parent == -1 => i is root bool dfs(int i, int parent) { if(EXIST(dp[i], parent)) return dp[i][parent]; bool flag = false; for(int j : g[i]) { if(j == parent) continue; flag |= dfs(j, i); } return dp[i][parent] = !flag; } int ans[N]; int main() { int n = ini; // グラフ構築 REP(i, n-1) { int a = ini - 1, b = ini - 1; g[a].PB(b); g[b].PB(a); } // iを根としてwinningなら追加 int k = 0; REP(i, n) { if(dfs(i, -1)) ans[k++] = i; } // output cout << k << endl; REP(i, k) { cout << ans[i]+1 << endl; } } //