_asmah98's blog

By _asmah98, history, 4 years ago, In English

Not sure why this code gives TLE.

Any help will be appreciated !

Link to Submission

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

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

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

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

There is no need of map and all those fancy stuff . Things will be faster and easier with bitmasking and bitwise operators . U can refer my code https://codeforces.com/contest/1341/submission/77843630

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

    Thank you! Tried removing maps but still TLE ! What's wrong with this approach ?

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

      Donot carry the string in the function parameter. Try to backtrack once you have written your dp. Taking strings in the parameter and doing so many addition of characters to strings are costly.

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

or you could just do it in o(n) with greedy