# CatFeed output as expected but still says wrong answer

Hi all, I’m a final year CS student and just did my 1st CP problem, it was the CatFeed one. I first solved it w/o producing the output as desired by the description, but then modified the code to accept input and produce output exactly as defined in the question, even tested it against the “example input” and it produced all output the same as the output displayed on the page, but when I submit it still says Wrong Answer. Can someone help me figure out why?

That problem has incomplete explanation in the problem statement. But test-cases give enough explanation…

I would suggest you to try some other problem as your first problem and don’t get stuck on this buggy one…

1 Like

But I didn’t get stuck! I solved it. It works as the question wants it to. I just can’t figure out what the site is claiming to be wrong with it.

May be you miss spell the variable name to some default answer.

I didn’t study your code properly but when I add “cout << “print this\n”;” immediately after your Testcases loop beginning, what happens is

Input:
3
4 6
1 2 3 4 1 2
3 5
1 2 1 3 2
2 4
1 2 2 1

Output:
print this
print this
print this
YES
NO
YES

Seems to me that you’re appending all inputs to a vector first and then computing the answers. I’m not sure if that’s the right approach.

If I’m understanding the problem correctly (its 0545 here XD), your solution fails the following testcase:

``````1
22 2
20 21
``````

Edit:

This is probably a better one:

``````1
20 2
11 10
``````
2 Likes

I have a function to check if an order is fair or not, and then in the main function I have a vector of pairs whose first element is a pair itself consisting of N and M, and the second is the order in which cats were fed. It reads each element of this vector and then feeds the values into the checking function and returns NO if it returned false and YES if it returned true. I’ll look into it further now.

UPDATE: I have found that the whole cin>> while looping part, when populating the vector which represents the order the cats were fed in, was not counting spaces because I was using char instead of string for each particular number, so when you input 20 21 for example, it would interpret it as 2 and 0. I switched to string and it works well now, and submitted it and it now says 100%.

Thanks for pointing out the misbehaving test cases!

1 Like