how to proceed for a interactive problem
like https://codeforces.com/contest/1491/problem/F
Interactive problem
check if this helps:
It seems this problem needs some random technique, but here is a determinate solution:
We just try to find a not demagnetized magnet.
You can go through the following method to find one:
First put the first magnet in the left.
Then ask all the other magnets with the left pile.
If we got a non-zero answer, we find a valid magnet; else we just put this magnet in the left.
It can be proven later that we will always be able to find a valid magnet.
Then use this magnet to try on all other magnets.
This process form a solution requiring at most 2n−2 queries.
However, when we look back at this solution we’ll realize that there is a huge waste of information in the previous queries.
As all the previous answers are 0, it’s easy to prove that the magnet we found is the second one we have selected.
Since we know nothing about the right part, we can simply check the magnets in the right one by one.
However, you have known that there is only 1 magnetic magnet in the left, so you can do a binary search to seek for the answer.
The maximum number of queries is n−1+⌈log2n⌉, which perfectly matches the limit.