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

akash.garg2172's blog

By akash.garg2172, history, 7 weeks ago, In English
Your code here...

I have tried this q :Aquamoon and Stolen String

And wrote the following code:

CODE

As per what I can observe my code is O(n*m) and in the q its mentioned that It is guaranteed that n is odd and that the sum of n⋅m over all test cases does not exceed 10^5.

But still my code is giving TLE in test case 2.

plz help me with its complexity

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

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

You are making vector ar of size 100005*30 T times

So if T is large your code will TLE

So make the vector ar only of size m as you are using no more

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

    Ohh yes Thanx Alot. I didn't knew that... Thanx bro

    • »
      »
      »
      7 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You are making your vector ar T times and each time you are making it of size 100005*30

      So your time complexity is O(T*100005*30)

      • »
        »
        »
        »
        7 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Yes thanx...Sorry.. its now accepted when I changed the size to m.