Please read the new rule regarding the restriction on the use of AI tools. ×

kmalhotra30's blog

By kmalhotra30, history, 7 years ago, In English

Hello codeforces community,

My submission Contest of DIV2A failed in system tests whereas it passed in practice after making one change Link.The only change i made was that i changed if(n-s.size()<0) to if(n<s.size()).I am unable to understand why the initial code didnt work.

Any help would be appreciated.

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

| Write comment?
»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

size() function always returns unsigned int and if u try to store negative numbers then it rotates the cycle and hence -1 is stored as 4294967295(Unsigned int MAX),-2 is stored as 4294967294(Unsigned int MAX-1),....

In test 12 s.size() returns 13 due to which becomes -s.size() becomes 4294967283. now n — s.size() = n + (-s.size()) = 1 + 4294967283 = 4294967284.

Happy coding :)