XOR_ORDER - Editorial

a,b,c is greater than 1 in constraint

I used another logic, like if ascending then the answer is 0, if descending then I used x as (A | (B^C)), as we know A > B > C, so A ^ (A | B^C)) what we can say is that lets as B and C are smaller their last position be say y’ and A before that doing xor with A will make it 0, and so we are left with xor of B xor C, for B ^ (A | B^C), will give us roughly equal to A|C, and for C similarly for C ^ X, it will give A|B, as A|B > A|C > B^C, so it convert it into required solution,
I know I don’t have much prove about it, but I used this as approximation, and it worked for me.

[i tired of multiple test cases but after i saw submissions i got surprised how was this codes gave ac ,then realized even with only a print statement of -1 the solution is getting accepted :sweat_smile: [Solution ](CodeChef: Practical coding for everyone)
There is something wrong with judge @youknow_who @yash_daga

weakest test cases , many got right , while i was struggling thinking actually cases , although authors approach seems true, but atleast i was thinking in my own way, while others with wrong codes got accepted. code force is better where hacks are done

3 Likes

i tried tester’s code but it’s showing wrong answer

1 Like

in tester’s code, why is he iterating 500 times can someone please explain it

Will they rejudge solution or not? I got AC on printing -1. At that time on running code it was showing same answer on sample test cases as well. Didn’t verify that again.

brother your code is giving wrong answer … please check what is the issue

He is generating random x and checking if it gives the answer XD

Same here brother

There was an issue with the judge, which should be fixed now. Tester’s code gets AC.

As @darshan_9405 mentioned, the tester’s code randomly picks an X and checks if it satisfies the condition.
This is provably correct with high probability, and the editorial also mentions this solution in its last paragraph.

If a solution doesn’t exist, it will definitely print -1.
If a solution does exist, a random X will be a solution with probability \geq \frac 18
Since the failure probability is \leq \frac 78, repeating 500 times makes the overall failure probability something like 10^{-29} which is so low that it’s never going to fail in practice.

1 Like

will the contest rankings be updated because there may be many submissions wrongly accepted ?

3 Likes

Just rejudge and adjust the rankings or make this round unrated,or this platform loses its trust, I’m leaving the platform anyways,
It’s not worth the effort to participate in contests and put efforts while people plagiarise and wrong submissions get AC.
There’s no point in putting efforts, codechef has diminished it’s quality a lot, work on it.

3 Likes

What about the people who lost ratings because of that?

1 Like

Please make the contest unrated or atleast give the rankings updated.
@iceknight1093
Why should we suffer for taking time and write correct logical code because of Codechef’s weak and wrong testcases

2 Likes

Exactly

This is what the announcement at the contest page says

In XOR_ORDER, the checker had an issue due to which some WA solutions have gotten an AC. This has been fixed for Practice. Since most affected participants did not use this ‘loop hole’ intentionally, we believe it is not fair to rejudge the submissions now, and are leaving it as it is. Apologies for the error.

1 Like

Seriously WTF

man, just saw a solution where user just iterating 0 to 10 and checking if there is ans and printing it and it got AC

1 Like

We don’t need 3 conditions to check for the bits.
The highest bit where a and b differ, b should have the bit on. If we are to have an answer, then b should have this bit on.
So we XOR a, b, c all at this bit and also add this bit’s value to X.
We do the same thing for b and c.
We don’t need to do it for a and c, as if a < b and b < c is satisfied, naturally, a < b < c will hold. Lastly, if this relation doesn’t hold, we know that answer doesn’t exist.
Here’s my solution for reference.
My submission
I like this problem.