Problem: 1678A - Tokitsukaze and All Zero Sequence
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!
Consider a case where all the elements of array are zero.
Thanks for your reply. The 'j' counts the zeros:
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.
check for 1 4 0 0 0 0
Found it, thanks a lot!
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.
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?
Dry run your submission on this testcase, printing the value of each variable after any modification.
Ticket 6767
https://codeforces.com/problemset/submission/1678/157702253