WHY THIS CODE DIDN'T ACCEPTED DURING COOK-A-CODE

There does not look any error.
So we can only guess.:smile:

3 Likes

Wow, how can you say that the brackets donā€™t make an answer wrong. There are multiple cases when because of the brackets, the answer received is different from than what was expected.
And I am not just making a random guess but an educated guess looking at the results.
I can only confirm once the problem is moved to practice and I can make some manipulations and submit his program.

5 Likes

but in that particular code all brackets are correctā€¦ i didnt said that in generalā€¦

This seems the most likely explanation to me.

2 Likes

But the guess is wrong. I submitted the same way and got AC

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin >> t;
	while(t--) {
        long long a, b;
        cin >> a >> b;
        if(a % (b + 1) == 0) {
            cout << "B" << endl;
        }
        else {
            cout << "A" << endl;
        }
	}
	return 0;
}
1 Like

Your code is different to the OPs.

4 Likes

Do you by any chance mean just because he put the bracket around n, a wrong answer came?

No; this bit in his code:

 if(n<=k)
        {
           cout<<"A\n";            
        }

would make the answer come out as A for N=0, whereas yours would be B. @sunil5798ā€™s hypothesis is that the constraints are wrong, and that one of the testcases has N=0. I also think this is the most plausible scenario.

5 Likes

i dont like when such thing happensā€¦ author should carefully make test casesā€¦ i am depressed that my team wasnā€™t able to solve this problem due to this issueā€¦:cry::cry::cry:

Yup, but according to the problem it should be A only(I guess, because he starts with 0). But yes, you have given me a possibility of why his answer can be wrong. Even though I didnā€™t understand how :thinking:

Well, we might be wrong and the testcases might be fine, but this is the only thing I can think of that would cause the OPā€™s code to give the wrong answer.

6 Likes

@ssjgz thanks for your timeā€¦but only one question remains in my mindā€¦ how to deal with such problems when my code is correct but still WA appearsā€¦ how to tackleā€¦ take this problem as exampleā€¦

This seems like the most plausible scenario. If you have a look at this code
https://www.codechef.com/viewsolution/30001819
You can see that it is the exact same solution, the only difference is that here there is an extra condition in the beginning
if(n==0) cout<<"B\n";
And this yields an AC.

5 Likes

wow, you checked all the codes?

2 Likes

Same problem with my code.
As this is constraints issue, Will @admin reconsider the submissions?

for _ in range(int(input())):
    n,m=map(int,input().split())
    if n<=m:
        print("A")
    elif n%(m+1)==0:
        print("B")
    else:
        print("A")

1 Like

@mittal_sahab please reconsider this if possible

@anon44231457 @sunil5798 @hblord787 , @ssjgz is right. Actually one of our test case file contains n=0, which is producing contradicting answers. We forgot to take this scenario into account while generating our test case file. We are really sorry for this blunder and inconvenience caused by it , hope you understand.

3 Likes

Hats off to @sunil5798 for correctly diagnosing it before everyone else :slight_smile:

1 Like

So the fault was in test case!

@anon44231457 , @hblord787, @rohit_iiitl : we wasted 3 hours on this wowā€¦ :rofl::rofl::rofl::rofl: that was a nice blunder. special thanks to @mittal_sahab