//Finding cycle in undirected graph.
//Maintain a parent
//if vis[i]==0 ,answer will be what is returned from next step
//else check if the pre checked node is not the parent
#define pb push_back
bool find_cycle(vector> &graph,int s,vector &visited,int par)
{
visited[s] = 1;
for (int i = 0;i < graph[s].size();i++)
{
if (visited[graph[s][i]] == 0)
{
if (find_cycle(graph,graph[s][i],visited,s) == true)
{
return true;
}
}
else
{
if (graph[s][i] != par)
{
return true;
}
}
}
return false;
}
int Solution::solve(int n, vector > &A) {
int m=A.size();
vector>v(n);
for(int i=0;ivisited(n,0);
for(int i=0;i