Why my answer is given WA verdict?

https://www.codechef.com/viewsolution/37152917

I tried submitting this as it worked fine for me but it’s given WA verdict. What’s the reason??
Problem Link:

They way your question is framed I originally thought that CodeChef was not accepting the solution as in you were not able to submit…like due to excessive load on servers

But, what makes you think that your answer is correct? It has been given WA verdict, which means that some testcases are not giving desirable output when you code is being tested. Check your logic…if you can’t do it, read editorials/ watch videos related to the prerequisites

Try edge cases and solve them manually and check them with the output your code gives

1 Like

I know that i’m given WA Verdict but when I try to run this code on the website then I get a Runtime Error(SIGTSTP). You can check that too.

I’ve tested this logic and it seems fine to me but I’ll still try some other logic.

Thank You!

Maybe you’re getting Runtime Error in Line 91

int b = inp[i+1] -'0';

For i = 2*n-1 , inp[i+1] will exceed array length.

Nope. That’s not the issue as the loop is running like this- i = 0, 2, ,4…n-2 and the program is running correctly in my IDE.

Thank You!

for a limited amount of test cases right? That means you need to think of testcases which will give you an incorrect output…
If literally anyone else has been able to solve the problem, then the chaces of the problem being wrong are slim (like 0.00X %)

1 Like

Consider the test input:

1
5
1100110100
2 Likes

Try out this testcase:

1
3
111011

The answer is 5.

1 Like

flash_0408 and ssjgz. Thank You! Now I know where I was wrong my program only output even shots. I’ll fix that. I probably should have tested it that way earlier.

2 Likes