[] [Meet in the mid qbxt2019csp brush class day1C title] birthday

Description

Given a length \ (n-\) sequence, a range of \ ([. 1, V] \) , each selection period interval, select a number of elements required in this interval is added to the two sets, each element or do not choose either to only one collection, a collection of non-empty and requires two elements are equal, ask can be achieved.

At the same time interval required to modify the elements of its cubic \ (V \) results modulo.

Limatations

\ (1 \ leq n \ leq 10 ^ 5 \) , \ (1 \ leq v \ leq 1000 \)

Solution

Consider a length of \ (len \) interval, consider each selected from the set point has not selected and set into the two possibilities, the number of types of a total of all of the selected \ (2 ^ {len} \ ) species. Since the range is considered \ (v \) , so the weight can occur and a total of \ (len \ times v \) species. When considering \ (2 ^ {len}> len \ times v \) when, must have at least two different selection got the same weight. Consider these two options might choose the same element, then directly to these same elements are removed, due to the same elements removed, and the resulting weights are still the same, and no two sets pay. Therefore, this case will be achieved.

Solving equations

\ [^ {2} as> as \ times the \]

Taken at both ends, \ (\ log \) , finishing to give

\ [Only - \ log only> \ log in \]

Obviously \ (V \) when the maximum value, the left side takes a maximum value, it is

\ [Only - \ log as> 10 \]

Obviously when \ (len \) when sufficiently large values of the left and \ (len \) positive correlation enumeration \ (len \) to give

\ [Len> 13 \]

Therefore, when \ (len \ geq 14 \) , the output may be directly \ (Yes \) , considered below \ (len \ leq 13 \) case.

The easiest way is to consider the burst search, each element of the enumeration is not selected or is selected from the set \ (A \) is selected from the set \ (B \) , the time complexity \ (O (3 ^ {len }) \) Since a total of \ (m \) queries, time complexity exceeded.

Consider meet in the middle, before the first search space \ (6 \) in all cases elements, recording all possible \ (A \) \ (B \) two collection element and the difference, the filter section \ (7 \) elements the case, also recorded all the possible elements and poor. Once there is a difference has appeared on both sides, you only need to choose a set of larger left choose the right small; left another set of selected smaller whichever is the larger of the right, you can get two legal collections, otherwise not be obtained.

Thus this Such complexity is \ (O (2 ^ {len / 2}) \) , because \ (m \) operations, actual operation amount \ (2 ^ 7 \ times m \) of the same order, may be by this question.

Consider interval modification operation, only the block or segment tree for quick maintenance.

Summary

zxy best in the world

Guess you like

Origin www.cnblogs.com/yifusuyi/p/11615771.html