Help in Sorting vases

Hello All,

Can anyone, after contest is over in few minutes, share here about why test case 9 and 10 were different from others, what logic did I miss ??

This is my solution

https://www.codechef.com/viewsolution/32909291

Greedy won’t work here. I too did greedy solution (but somehow got AC :p)
Check editorial here : SORTVS - Editorial

Can you suggest any test case where it wont work. I will check the editorial, but I cannot think of any case, it will not work.

I too have asked author on editorial page. Lets see what he has to say.
Will share here if I find any.

Okay. Thanks !
Please do reply if you find one.

1 Like

Try this one

1
8 4
2 3 4 1 6 7 8 5
1 5
2 6
3 8
4 7

I used logic where I translated permutation into cycles and then assumed if two cycles are disjoint then there will always be a solution which does not combine those cycle. But I was wrong. And above is the counter test case.

This fails on her code. But mine still passes :frowning:

1 Like

Thanks

would you share a link to your code?

Sure thanks : https://www.codechef.com/viewsolution/32819367
It fails on test case 9


I think this can be an issue.

https://www.codechef.com/submit/SORTVS i want to know which test cases fails my code?
or the whole approach is wrong?