Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

ARYANK3024's blog

By ARYANK3024, history, 17 months ago, In English

I am getting MLE for this code https://mirror.codeforces.com/contest/1774/submission/186717963 Please Anyone Can help?

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

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

Hey man, i solved ur memory problem with the following submission: https://mirror.codeforces.com/contest/1774/submission/186734301

However, I got a time limit exceeded on the next test (22). Do u think u could give me a time complexity analysis for ur code to see what is the problem?

  • »
    »
    17 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    for my code the time complexity was O(n); where n is number of nodes

    • »
      »
      »
      17 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      can u double check this please because my changes have not affected anything in your code but it is giving time limit exceeded on testcase 22.

      • »
        »
        »
        »
        17 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        The one thing more i have done is predefining the size of curr vector so to avoid mutliple times reallocation of size of the vector

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

Now i gets accepted by passing the visited vector by reference... !!

Thanks @TheOpChicken123 for pointing out.

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

Pass the reference for visted and curr vectors and make the necessary changes in update() and DFS() functions.

This is ACCEPTED submission of your code.

1st Change
2nd Change

Hope you got it right :)