jzoj5652 [NOI2018 simulation 4.14] [color] and [tears]

write picture description here
n<=1e5,ai<=1e9

Conclusion questions

Part1

Consider the case where se takes last.
At the beginning, we record n ​​divided by two and round it up as the gap, and first pair i with i+gap.
Considering the parity of n, it is not difficult to find in the process of taking.
In either case, there is a way to take se so that:
if the current se is taken, there must be an unpaired one.
If it is currently taken by liu, it must be a good match.

For se, we can remove the unpaired one so that we end up with a pair, so the lower bound of the answer is on the pair with the smallest distance.
For liu, we can choose the smallest pair at the beginning, and then remove the outer sides of the muffler. Calculate just to take out all the outside. The upper bound of the answer thus obtained is on the smallest pair.

In summary, when se is finally taken, the answer is the smallest pair.

Part2

Consider liu to take last.
The answer is dichotomous, consider whether liu can limit the answer to mid (inclusive)

Divide a into several segments starting from 1, satisfying the distance of each segment <=mid and the distance between the beginning of the segment and the beginning of the next segment >mid.
First give the conclusion: liu can limit the answer to mid if and only if the number of segments <=n/ 2 round up

Proof idea: Induction.
On the condition that the number of segments x<=n/2 is rounded up, it
is now necessary to prove that when there are i steps left in liu, the number of stone piles does not exceed i+1.
Obviously the initial state satisfies this condition. Assuming that there are i steps left in the current liu and the number of piles is exactly i+1, then there is at least one stone in a pile (calculate the number of remaining stones). Remove it, at this time, the number of steps and the number of heaps are reduced by one. Summarized.

So when it's done, there's only one segment left. So the upper bound on the answer is mid.

Obviously, when the number of segments>n/2 is rounded up, se can increase the answer to more than mid.
Reason: liu cannot take the remaining one segment header because the number of times is not enough. As long as se is not done, the lower bound of the answer is guaranteed to be mid+1.

It can be found from the above proof that both the selection of the gap and the selection of the segment number boundary are closely related to the number of times the two people take.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325416492&siteId=291194637