_asmah98's blog

By _asmah98, history, 5 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

»
5 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).

»
5 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.me/contest/1341/submission/77843630

  • »
    »
    5 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 ?

    • »
      »
      »
      5 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.

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

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