Wrong answer error

I am unable to find any error in my solution and when i execute this program it runs without any error, but when i submit the answer it is showing wrong answer error.please help

Hey Santosh, I went through your code and found out the reason you are getting WA verdict is because your code is incorrect. (No shit sherlock)
By incorrect I don’t mean that it crashes but rather that it outputs a wrong answer.
Example : YES might be expected but your code outputs NO.
The single test case you see is only an example. Once you submit your code it runs on several hidden testcases which are never shown to us.
The work you have to do now is to find that testcase for which your code is giving the wrong answer. This step is actually the most fun and also the most frustrating! Maybe you are missing a single testcase or maybe you’ll have to rewrite the whole code again!
You can also look at other people’s AC submissions if you want a clue or have officially given up.
I typed up this whole message after seeing that you are new on Codechef (Welcome aboard!) and thought that this might be helpful.


Firstly, if you are still looking for the testcase where your program fails, here it is :

1 2 3
2 4 8
2 5 9

Answer should be


Your output :


As @greyhound suggested finding the testcase where your code fails is a good way to go. Another (slower?) way is to try and prove the correctness of your solution, but for this prereqs are rather high; this actually makes you feel commando.

The mistake (in the idea of solution) is that you did not separate the case when we know the last answered query was a “YES” or “NO”. This is important because if last one was a “NO”, except for b = c case, answer will always be a “NO” as we had no clue earlier how will we know now.

PS : There is no guarantee (strictly speaking) that an ACed (Answer Correct verdict) code is right and no guarantee that WAed code is incorrect. Both of them are highly unlikely, but later one is almost nonexistent.