Faulty Test Cases in ONEVALUE

solution
problem link
please provide some good test cases where my code is failing

Bhai koi to dekh lo ek baar. test case bata do bus.

There is no option for submit. I think author currently not accepting any solution or maybe thing is only happening with me. So bro be patient i’ll reach you with answer of your Query ASAP :smiley:

1 Like

Take the following test case:
10
1 1 1 1 1 1 2 1 3 1

Your code outputs 2, whereas the following accepted submissions output 3.
https://www.codechef.com/viewsolution/34443997
https://www.codechef.com/viewsolution/34420421
https://www.codechef.com/viewsolution/34436990

Now, I think that the answer must be 2, and my code also outputs 2.
So, either both of us misinterpreted the question, or their is some serious problem with the test cases.

Having said that there might be some other issues too with your code, but you might want to start with this.

1 Like

not only you…i can’t submit either

Thank you bro.

Thanks bro

I requested some sample test cases from the author. Got this:
I/P

25 10 8 9 8 7 4 8 4 10 4 7 8 2 7 6 10 10 6 1 4 3 9 5 4 5

O/P

19

This proves that the author’s answers to the test cases are suboptimal.
My code outputs 17 which is optimal that’s why I got WA.

I can achieve my answer using the following 17 moves.

i/p: [10, 8, 9, 8, 7, 4, 8, 4, 10, 4, 7, 8, 2, 7, 6, 10, 10, 6, 1, 4, 3, 9, 5, 4, 5]

  1. [10, 8, 9, 8, 7, 4, 8, 4, 10, 4, 7, 8, 7 , 7, 6, 10, 10, 6, 1, 4, 3, 9, 5, 4, 5]
  2. [10, 8, 9, 8, 7, 4, 8, 4, 10, 4, 7, 7 , 7, 7, 6, 10, 10, 6, 1, 4, 3, 9, 5, 4, 5]
  3. [10, 8, 9, 8, 7, 4, 8, 4, 10, 4, 7, 7, 7, 7, 10 , 10, 10, 6, 1, 4, 3, 9, 5, 4, 5]
  4. [10, 8, 9, 8, 7, 4, 8, 4, 10, 4, 10, 10, 10, 10 , 10, 10, 10, 6, 1, 4, 3, 9, 5, 4, 5]
  5. [10, 8, 9, 8, 7, 4, 8, 4, 10, 10 , 10, 10, 10, 10, 10, 10, 10, 6, 1, 4, 3, 9, 5, 4, 5]
  6. [10, 8, 9, 8, 7, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 , 6, 1, 4, 3, 9, 5, 4, 5]
  7. [10, 8, 9, 8, 7, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 , 1, 4, 3, 9, 5, 4, 5]
  8. [10, 8, 9, 8, 7, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 , 4, 3, 9, 5, 4, 5]
  9. [10, 8, 9, 8, 7, 4, 4 , 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 9, 5, 4, 5]
  10. [10, 8, 9, 8, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 , 3, 9, 5, 4, 5]
  11. [10, 8, 9, 8, 9 , 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 9, 5, 4, 5]
  12. [10, 8, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 , 9, 5, 4, 5]
  13. [10, 8, 9, 9 , 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, 4, 5]
  14. [10, 8, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 , 5, 4, 5]
  15. [10, 5 , 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5]
  16. [10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 , 5]
  17. [ 5 , 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]

Try generating random test cases and test your code against brute force, if outputs match then your code is mostly optimal.

Although, if your solution is accepted to ONEVALUE, then it’s surely suboptimal, because the author’s solution is suboptimal.

so problem is with test cases right?

yes, that’s why there are so few accepted submissions.

It will be helpful if you could change title of your post to faulty test cases, it will help others to who where struggling with the same issue.

no, it is giving WA, also I have tried hundred’s of test cases, for the above code my code is giving output 16.

Try to print the moves using your code, and check if they are valid, either 16 is the optimal answer or your code is incorrect. Only way to verify is to print the moves your code is taking to get to 16.

yes checking my code output i will tell you.

For input
25
10 8 9 8 7 4 8 4 10 4 7 8 2 7 6 10 10 6 1 4 3 9 5 4 5
following moves are possible

  1. 10 8 8 8 7 4 8 4 10 4 7 8 2 7 6 10 10 6 1 4 3 9 5 4 5
  2. 10 8 8 8 7 4 4 4 10 4 7 8 2 7 6 10 10 6 1 4 3 9 5 4 5
  3. 10 8 8 8 7 4 4 4 4 4 7 8 2 7 6 10 10 6 1 4 3 9 5 4 5
  4. 10 8 8 8 7 4 4 4 4 4 7 8 2 7 6 10 10 6 1 4 3 9 5 5 5
  5. 10 8 8 8 7 4 4 4 4 4 7 7 7 7 6 10 10 6 1 4 3 9 5 5 5
  6. 10 8 8 8 7 4 4 4 4 4 7 7 7 7 6 6 6 6 1 4 3 9 5 5 5
  7. 10 8 8 8 7 7 7 7 7 7 7 7 7 7 6 6 6 6 1 4 3 9 5 5 5

ans 16;

I have observed that if a sequence is of the form
a a b b c c
then answer will be the Number of different types of element -1.
so in the above case answer will be 2 (as a b c three different elements ).
so in the first test case
ans=0;
in
1 move ans=1
2 move ans=2
3 move ans=3
4 move ans=4
5 move ans =ans+2=6 ([7 8 2] ans will be 2)
6 move ans=ans+1=7
7 move ans=ans+1=8;

in 7th move our string becomes of form a a b b c c …
ans=ans+8=16;(9 different types of element)
am i correct ?

Bro do check my solution if possible

Same Question

That’s correct, There was some bug in my code, now its working fine, and outputting 16 for the above test case.

Although your code was giving optimal answer for the above code, its still not correct.
Consider the following test case.

10
1 1 1 1 2 3 1 1 3 2

Your code outputs 4, correct answer is 3

1 Like

Yes, the idea to solve is same

1 Like