XORSEQ
anyone plz help me why my solution getting runtime error for a subtask.I got 20 marks for the solution and it is absolutely fine with the sample case.please help me to remove it https://www.codechef.com/viewsolution/30746067
I think your logic is : If two nodes are part of a cycle then there will be a different part other than the edge path.
The DFS part is a slight modification of printing all the cycles in graph algorithm.
Consider a fully connected graph with N nodes. Then cycles will be formed if we pick any number of nodes between [3 - n].
So total number of nodes that will contibute in cycle will be : 3 * nC3 + 4 * nC4 …+ n* nCn ~= n2^n … so the worst case complexity will be n2^n.
I also used the same code from GFG article in contest seeing its complexity O(n+m) and got TLE. I think the complexity is mentioned wrong there.
Better use the Atriculation points and bridges technique to see if removing the edge makes the two nodes unreachable from each others and increment ans accordingly.
My logic is exactly what you said and i think you are right. Thanks for the help and this complexity is a big mistake at GFG have you confirmed this from somewhere else also ?