Note: I am not sponsored by the JOISC committee, if the committee is not ok with prizes, I will remove them.
I have managed to solve this problem with $$$n=45000$$$. As far as I know, the person with the highest $$$n$$$ other than me is EvenImage who has achieved $$$n=44000$$$ in this comment.
I think this problem is quite interesting to constant optimize, so I am offering prizes for people who can improve the solution. The prizes work as follow:
- For every increase of $$$\min(\lfloor \frac{n}{100} \rfloor,460)$$$ by $$$1$$$, I will give the person 5USD (sorry, I'm still a broke student).
- You must link a submission of your code on oj.uz that is AC.
- You must state the value of $$$n$$$, rounded down to nearest $$$100$$$, that your code works in under $$$1$$$ million queries.
- As a bonus, you can explain what your optimizations are (well, I would like to know how you were able to optimize this problem).
- If this limits of $$$n$$$ turns out to be too hard, I might make the conditions more lenient.
I'll start first.
This is my solution: https://oj.uz/submission/619999. It can barely solve $$$n=45000$$$. The maximum number of queries used in $$$10$$$ random tests is $$$999920$$$.
Good luck!
UPD: The maximum value of $$$n$$$ has been capped to $$$46000$$$, I think $$$50000$$$ was probably too unrealistic of a goal.








Hello, how should i use the test case generator?
What I was thinking was to output the test case generator output into a file and then input from that same file when i test my code. Is that how I should do it or is there a better way?
Thank you
Hi, I think I can solve for $$$N=47200$$$ submission. The idea of solution is a parallel binary search. Firstly, let's notice that when the pile is full we can assume that it is empty just keeping the tag is it reversed or not. So let's pick numbers from $$$1$$$ to $$$2N$$$ in some order and get the answers. (Before everything we shuffled indices). Firstly, let's traverse from $$$1$$$ to $$$2N$$$ to determine which indices are "right" and which are "left". Then for each right index we should find its left index. Let's do the iterations of binary search, in one iteration we will add "left" indices to the initially empty pile and do the binary search by the right indices, adding it in the moment it needs to be added.
Without any optimizations it works just for $$$N=32000$$$ or so. But we can
1) skip the pairs we already know
2) (The most important!) Check the possibility of the pair by the previous queries, and move left and right bounds for each element if the borders are impossible.
3) try to guess for left index whether there is only one right index
With this optimizations you can get $$$47200$$$. I suppose you can do some other optimizations here (like erasing last $$$\approx \sqrt{N}$$$ queries from the end of each sequence) and increase $$$N$$$ further.