sumantopal07's blog

By sumantopal07, 4 months ago, In English

https://cses.fi/problemset/task/1669/ I was solving this problem and my simple approach to detect the cycle is to store the current path in a vector and when i encounter a duplicate in cycle, I print it. But Issue is 3 test cases are giving me WA out of 20. Also test cases are really huge to debug the issue with my code. Any help will be thankful

My Submission
 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
4 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Try this case...

4 4

1 2

1 3

3 4

1 4

Hope now you can debug your code yourself :)

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it
»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

i think beacause you are not poping back as soon the dfs of that node has been completed is creating all that trouble