Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

Sukeesh's blog

By Sukeesh, 8 years ago, In English

Hello everyone,
I have been trying this problem
My Solution is getting Memory Limit Exceeded (even though I don't think, I have declared anything Memory consuming)
Can someone please help me?

EDIT : figured out my mistake! AC

  • Vote: I like it
  • -4
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Your DFS is incorrect, it will not work on graphs with cycles. For some reason ML happens way earlier than TL should happen, most likely because each call of DFS allocates another 4x(long long) memory.

Testcase example
»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Sukeesh (previous revision, new revision, compare).