/** * @FileName a.cpp * @Author kanpurin * @Created 2020.10.10 01:43:59 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; struct LowLink { private: vector< vector< int > > G; int V; vector< int > used, ord, low; int dfs(int idx, int k, int par) { used[idx] = true; ord[idx] = k++; low[idx] = ord[idx]; bool is_articulation = false; int cnt = 0; for (auto &to : G[idx]) { if (!used[to]) { ++cnt; k = dfs(to, k, idx); low[idx] = min(low[idx], low[to]); is_articulation |= ~par && low[to] >= ord[idx]; if (ord[idx] < low[to]) bridge.push_back(minmax(idx, (int)to)); } else if (to != par) { low[idx] = min(low[idx], ord[to]); } } is_articulation |= par == -1 && cnt > 1; if (is_articulation) articulation.push_back(idx); return k; } public: vector< int > articulation; vector< pair< int, int > > bridge; LowLink(int V) : V(V) { G.resize(V); } void add_edge(int v, int u) { G[v].push_back(u); G[u].push_back(v); } void build() { used.assign(V, 0); ord.assign(V, 0); low.assign(V, 0); int k = 0; for (int i = 0; i < V; i++) { if (!used[i]) k = dfs(i, k, -1); } } }; int main() { int n;cin >> n; LowLink g(n); vector> edge(n); map,int> mp; for (int i = 0; i < n; i++) { int a,b;cin >> a >> b; a--;b--; edge[i] = {a,b}; mp[{a,b}] = i+1; g.add_edge(a,b); } g.build(); cout << n - g.bridge.size() << endl; for (auto p : g.bridge) { mp[p] = -1; } for (int i = 0; i < n; i++) { if (mp[edge[i]] != -1) cout << i+1 << " "; } cout << endl; return 0; }