#include #include #include #include #include #include #include #include #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 P = pair; constexpr int INF = 1001001001; // constexpr int mod = 1000000007; constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } template struct LowLink{ const G& g; vector visited, order, low; vector articulation; // 関節点 vector> bridge; // 橋 (order[from] < low[to]) int LinkSize = 0; // 連結成分の個数 LowLink(const G &g) : g(g) {} int dfs(int from, int k, int par = -1){ visited[from] = true; order[from] = k++; low[from] = order[from]; bool is_articulation = false; int cnt = 0; for(auto &to : g[from]){ if(!visited[to]){ ++cnt; k = dfs(to, k, from); low[from] = min(low[from], low[to]); // 頂点 from がDFS木の根以外であるときの関節点となる条件 is_articulation |= ~par && low[to] >= order[from]; // (from, to) が条件を満たせば、橋に追加 if(order[from] < low[to]) bridge.emplace_back(minmax(from, (int)to)); } else if(to != par){ low[from] = min(low[from], order[to]); } } // 頂点 from がDFS木の根であるときの関節点となる条件 is_articulation |= par == -1 && cnt > 1; if(is_articulation) articulation.push_back(from); return k; } virtual void build(){ visited.assign(g.size(), 0); order.assign(g.size(), 0); low.assign(g.size(), 0); int k = 0; for(int i = 0; i < g.size(); ++i){ if(!visited[i]){ k = dfs(i, k); ++LinkSize; } } } }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector a(N), b(N); vector> graph(N); for(int i = 0; i < N; ++i){ cin >> a[i] >> b[i]; --a[i], --b[i]; graph[a[i]].emplace_back(b[i]); graph[b[i]].emplace_back(a[i]); } LowLink>> g(graph); g.build(); set

bridge; for(auto [u, v] : g.bridge){ bridge.emplace(minmax(u, v)); } vector ans; for(int i = 0; i < N; ++i){ if(bridge.find(minmax(a[i], b[i])) != bridge.end()) continue; ans.emplace_back(i + 1); } int n = ans.size(); cout << n << '\n'; for(int i = 0; i < n; ++i){ cout << ans[i]; cout << ((i == n - 1) ? '\n' : ' '); } return 0; }