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 ).
Contest submission 25046285
First submission after contest 25087377 (only added getchar(), immediately after cin )
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 :)
Klasican papak...
Thanks for reply ! But sorry I do not understand Bosnian :P
What papak means? Is it solution for this problem?
Papak means hoop literally, but I think that fulu wants to be one of the funny guys. Unfortunately unsuccessFULU :D
I thinked it means Knapsack Problem)
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.
Sorry I posted wrong submission as second code. Now you can see code with getchar().
You need
getchar()
orgetline()
right after firstcin
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 lineif (sz[i]==3)
.