Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя kmalhotra30

Автор kmalhotra30, история, 7 лет назад, По-английски

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.

  • Проголосовать: нравится
  • -7
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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 :)