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

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

I submitted the following solution for today's B during the contest: http://mirror.codeforces.com/contest/1005/submission/40123027 But even later when i saw the test case, i couldn´t figure out what i did wrong, cause i think my logic is correct. Can someone explain why is my algorithm failing? Are there any corner cases in this problem?

Thanks in advance, have a great day.

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

»
6 лет назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

Consider the case which first string is aaaa and second string is aabb. k should be 0,but your loop increases k two times, when it shouldn't. Your solution fails when you should delete all characters but your loop finds identical characters.

  • »
    »
    6 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Yeah, thanks for the help, i should've stopped the for when the two elements were distinct.