#include "bits/stdc++.h" using namespace std; //#include "atcoder/all" //using namespace atcoder; #define int long long #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i) #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i) #define ALL(a) a.begin(), a.end() #define IN(a, x, b) (a <= x && x < b) templateistream&operator >>(istream&is,vector&vec){for(T&x:vec)is>>x;return is;} templateinline void out(T t){cout << t << "\n";} templateinline void out(T t,Ts... ts){cout << t << " ";out(ts...);} templateinline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;} templateinline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;} constexpr int INF = 1e18; struct Edge { int to; }; using Graph = vector>; using P = pair; /* Lowlink: グラフの関節点・橋を列挙する構造体 作成: O(E+V) 関節点の集合: vector aps 橋の集合: vector

bridges */ struct LowLink { const Graph &G; vector used, ord, low; vector aps; // articulation points vector

bridges; LowLink(const Graph &G_) : G(G_) { used.assign(G.size(), 0); ord.assign(G.size(), 0); low.assign(G.size(), 0); int k = 0; for (int i = 0; i < (int)G.size(); i++) { if (!used[i]) k = dfs(i, k, -1); } sort(aps.begin(), aps.end()); // 必要ならソートする sort(bridges.begin(), bridges.end()); // 必要ならソートする } int dfs(int id, int k, int par) { // id:探索中の頂点, k:dfsで何番目に探索するか, par:idの親 used[id] = true; ord[id] = k++; low[id] = ord[id]; bool is_aps = false; int count = 0; // 子の数 for (auto &e : G[id]) { if (!used[e.to]) { count++; k = dfs(e.to, k, id); low[id] = min(low[id], low[e.to]); if (par != -1 && ord[id] <= low[e.to]) is_aps = true; if (ord[id] < low[e.to]) bridges.emplace_back(min(id, e.to), max(id, e.to)); // 条件を満たすので橋 } else if (e.to != par) { // eが後退辺の時 low[id] = min(low[id], ord[e.to]); } } if (par == -1 && count >= 2) is_aps = true; if (is_aps) aps.push_back(id); return k; } }; signed main(){ int N; cin >> N; Graph g(N); vectora(N), b(N); REP(i, N) { cin >> a[i] >> b[i]; --a[i]; --b[i]; Edge A, B; A.to = a[i]; B.to = b[i]; g[a[i]].emplace_back(B); g[b[i]].emplace_back(A); } auto ll = LowLink(g); vectorans; REP(i, N) { if(ll.ord[b[i]] < ll.low[a[i]]) ans.emplace_back(i); if(ll.ord[a[i]] < ll.low[b[i]]) ans.emplace_back(i); } sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); //out(ans.size()); setst; REP(i, N) st.insert(i); REP(i, ans.size()) st.erase(ans[i]); ans.clear(); for(auto e: st) ans.emplace_back(e + 1); out(ans.size()); REP(i,ans.size())cout << ans[i] << " \n"[i+1 == ans.size()]; }