lucas1809's blog

By lucas1809, 4 years ago, In English

I was trying to solve round 656, question D (div3), and thought my logic in question D was right, but It's giving a wrong exit code in test case 3, causing TLE

https://codeforces.com/contest/1385/submission/87354850 <- code

My logic was using dp to find the minimum route of moves necessary. I use the function "contar" to count the number of moves necessary for the left part of the string and the right part, and recursevely use "solve" to get the best answer.

Also, is there a way to copy and paste the test cases used on the judge? I can't test -test case 3-, because It's too long, which is frustrating.

Thanks in advance. I would really apreciate it if you could help me

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

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

Your recursive function copies a whole string in every call, and comlexity is being O(N^2).

Just add a reference to it like string &s

UPD: AC

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think there is no such feature as copy or download the testcases on codeforces but I hope it will be added soon. :)