void find_cycle(){ color.assign(n, 0); // Directed graph visited.assign(n, false); // Undirected graph parent.assign(n, -1); cycle_start = -1; for(int v = 0; v<n; v++){ if(color[v] == 0 and dfs(v)){ break; } } if(cycle_start == -1){ //cout << "Ascyclic Graph"<<endl; //cout << -1 << endl; cout << "IMPOSSIBLE"<< endl; } else{ std::vector<int> cycle; cycle.push_back(cycle_start); for(int v = cycle_end; v != cycle_start; v = parent[v]){ cycle.push_back(v); } cycle.push_back(cycle_start); reverse(cycle.begin(), cycle.end()); // sort(cycle.begin(), cycle.end()); cout << cycle.size()<< endl; for(int v:cycle){ cout << v+1 <<' '; } } }