// #pragma GCC optimize("O3") // #ifndef ONLINE_JUDGE // #define _GLIBCXX_DEBUG // #endif #include using namespace std; void solve() { int N; cin >> N; vector>> adj(N); for (auto i = 0; i < N; ++i) { int u, v; cin >> u >> v; --u, --v; adj[u].push_back({v, i}); adj[v].push_back({u, i}); } vector visited(N); vector tin(N, -1), low(N, -1); int timer = 0; vector color(N); auto dfs = [&](auto self, int u, int par) -> void { visited[u] = true; tin[u] = low[u] = timer++; for (auto [v, i] : adj[u]) if (v != par){ if (visited[v]) { low[u] = min(low[u], tin[v]); } else { self(self, v, u); low[u] = min(low[u], low[v]); if (low[v] > tin[u]) { color[i] = 1; } } } }; dfs(dfs, 0, 0); cout << count_if(begin(color), end(color), [](auto x) {return !x;}) << '\n'; for (auto i = 0; i < N; ++i) { if (!color[i]) { cout << i + 1 << ' '; } } } auto main() -> signed { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); solve(); return 0; }