### setuid0's blog

By setuid0, history, 2 months ago,

Verdict: Wrong answer on test 8

Checker comment: wrong answer 986th numbers differ — expected: '0', found: '-1'

This is my submission: 156338916

1: When scrolling through the submission list, including other contenders, I didn't find another verdict with 'Wrong answer on test 8'. (At least not so far, I will continue looking for it.)

2: I tried to use submit again without a "\n" at the end. Same verdict.

3: Memory looks okay.

4: Time looks okay.

5: When looking through the testcase details, is there a way to see the exact testcase input/output instead of the '...'?

6: Numbers aren't to big for int, so long or long long isn't needed.

7: Could there be a problem with my size_t in the for loop?

8: What am I missing here?

Any help regarding this is highly appreciated.

Kind regards and happy coding,

setuid0

edit: This is the corrected and accepted solution:156359415 The Problem was the while loop for all elements zero. Thanks for the help!

• +3

 » 2 months ago, # |   0 Consider a case where all the elements of array are zero.
•  » » 2 months ago, # ^ |   0 Thanks for your reply. The 'j' counts the zeros: while (vec[j] == 0) { ++j; } if (j > 0) { return vec_size - j; } I was thinking the same, but in test 2 we already have multiple cases of all elements being zero.'vec_size — j' will return 0 for these cases.
•  » » » 2 months ago, # ^ |   0 check for 1 4 0 0 0 0
•  » » » » 2 months ago, # ^ |   0 Found it, thanks a lot!
 » 2 months ago, # |   +3 You cannot use a while (vec[j]==0) because it will go out of bounds when all of the elements are 0. It is only because of C++ you get wrong answer instead of runtime error. You have to use a normal for loop or a for-each loop.
•  » » 2 months ago, # ^ |   0 Thanks for your reply. I will look into that! Is there any reason why the testcases from test 2 onwards where all elements are zero are working fine and only at test 8 we get the problem?
 » 2 months ago, # |   +1 Dry run your submission on this testcase, printing the value of each variable after any modification.
 » 7 weeks ago, # |   0