Code Chef Starters 143, 17th July 2024; Problem 2: Binary Conversion #CONVERT;

Describe your issue

The testcases are wrong. The 2nd test suite throws wrong answer for my code.

The problem is this:

The logic assumed by the testcases provider is, if there are n indices that are mismatched (such that number of 1s & 0s are same for both strings), then n/2 operations are required to make S==T. If K<n/2 print “NO”, else if k==n/2 print “Yes”, else if (k-n/2)%2==0 print “Yes”, else print “No”.

Now, The Problem, consider the below testcase:

S: 0 1 0 1 0 1 0
T: 1 0 0 1 0 0 1
K=3

indices (0,1) & (5,6) can be swapped (2 operations) to make S & T equal. But, K=3 & 3-2=1 which is odd. Hence, the test case assumes answer is “No”.

But you can use that remaining 1 operation to swap indices 2&4 , and still have S==T at the end. Hence, my code prints “Yes”. The question just says print “Yes” if it can be done in exactly K operations. It can be done, so “Yes”.

Please look into this issue. Urgent

Screenshot

Additional info

Code Chef Starters 143, 17th July 2024; Problem 2: Binary Conversion convert; Division 3;