Problems_AB's blog

By Problems_AB, history, 4 years ago, In English

Hi All, I'm getting memory limit exceeded on test 2, when I'm submitting the code. I'm not able to find out the reason. I would be really grateful to you all if someone could help me and tell me why I'm getting memory limit exceeded. TIA Here is my submission: 101191361

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

One solution is declaring all the vectors and arrays as global. Then u dont need to pass them to your DFS functions.

»
4 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

Hi All, I got accepted when I changed one line in my code. In the dfs function where I'm finding the cycle, if I write par[a]=p below the if(color[a]==1) condition instead of above it then everything works fine. Can someone tell me why it was wrong before and why was this one line causing MLE. TIA