allllekssssa's blog

By allllekssssa, history, 8 years ago, In English

Hi,

I was doing previous div 1 round and I got WA on the second task ( 33rd testcase). I wasn't able to understand why I got Wrong Answer, so I asked question on contest blog and had a few answers. They were very helpful, but still I do not understand whole sotry about my mistake and some different outputs of my program ( all programs looks same for me ).

  1. Contest submission 25046285

  2. First submission after contest 25087377 (only added getchar(), immediately after cin )

  3. Second submission after contest 25087412 (I changed place of getchar(), and wrote it one line above)

I understood why I needed to add one extra getline(), but I do not understand why getchar() is needed and why second and third submissions gives different verdicts.

I will be grateful for any help :)

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

»
8 years ago, # |
  Vote: I like it -15 Vote: I do not like it

Klasican papak...

  • »
    »
    8 years ago, # ^ |
      Vote: I like it +19 Vote: I do not like it

    Thanks for reply ! But sorry I do not understand Bosnian :P

  • »
    »
    8 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    What papak means? Is it solution for this problem?

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it +10 Vote: I do not like it

      Papak means hoop literally, but I think that fulu wants to be one of the funny guys. Unfortunately unsuccessFULU :D

  • »
    »
    8 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    I thinked it means Knapsack Problem)

»
8 years ago, # |
  Vote: I like it +2 Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +5 Vote: I do not like it

I see no getchar() in the 2 submission. It is needed to remove the '\n' character that is left in the buffer after you read n and m.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Sorry I posted wrong submission as second code. Now you can see code with getchar().

»
8 years ago, # |
Rev. 3   Vote: I like it +16 Vote: I do not like it

You need getchar() or getline() right after first cin to skip new line (\n char) after the first input line, so, getline in next cycle will read from the second input line. Verdicts for your 2 and 3 solutions have a difference because of cycle conditions difference before line if (sz[i]==3).