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

Автор CaP_TaIn, 5 недель назад, По-английски

During solving this problem(Problem Link) I first used set for maintaing count of the cases but it was giving wrong ans on test5 but when I used integer for count it passed all test cases and i'm unable to find why using set giving wrong ans.

here are my submissions : 1)using set:286839990 2)using integer:286840330

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

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

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

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

to me both seems similar and correct. I'm also interested to know why set one fails

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

Your submissions have differences other than counting with set/int. In the set submission, you have

if (str.substr(r, 2) == "LR")

and in the integer one, you have

if (str.substr(r, 2) == "LR" && mx[r]!=r+1)

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

    yeah,i thought that if the value is not in set erasing it will like doing nothing but after you pointed out this i tried after checking if it present in set or not then if it's present then i deleted and it worked...so i think erasing not present value in set was giving error...Thanks man!!!