I wanted to know for which test case my code produces wrong output , bcoz i have failed to pass few test cases
problem:- https://www.codechef.com/problems/GERMANDE
code:- https://www.codechef.com/viewsolution/14274591
plz help me
I wanted to know for which test case my code produces wrong output , bcoz i have failed to pass few test cases
problem:- https://www.codechef.com/problems/GERMANDE
code:- https://www.codechef.com/viewsolution/14274591
plz help me
thanks for letting me know
You’re failing on this test case:
1
1 5
1 0 0 0 0
Expected output:
0
Your output:
1
Do look at your else
block, I think that fixing it will be enough enough to get your AC
I tried more test cases, apparently you also have an error in your first if
block. Try this test case:
1
9 3
0 1 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 1 0 1 1 0 0 1
The correct output is 0
while your code is giving output 1
. Hope you find that bug.
Found your bug. There can be cases when j>o2
. For that, your i
in your inner loop, given i=o2+j
(line 29), can exceed the total size of the array after a couple of iterations. What you can do to fix this is to do i=j%o2+o2
instead, to make sure that the first iteration is within the first range.
thanks bro i got it
In first for loop condition I wrote j<o1 BUT it should be j<o2
Thanks dude
BTW how u obtained the input(above one) for which my code produced wrong answer
Oh that’s great! Just generated random input to check your program with a while loop :))