ZROI 19.08.08 simulation game

Portal

EDITORIAL: In order to protect copyright is Rui topic, here and hold surface title, write only problem solution.


Congratulations swk roll today!

"Be careful you play a large sample." - Tianqi pigeon pigeon

Sure enough swk today play a large sample is dead, Tianqi pigeon pigeon honest not bully me!


  • A

This is a question mark away a few days ago a dual-stack backpack ACM race ......

However, after sorting can be directly backpack, \ (O (nm) \) just been (


  • B

Vegetable dishes swk

The answer is found in the longest substring border, that is the shortest cycle minus long string section.

Each letter is independent and can be calculated separately for the answer.

The first \ (I \) letters, provided loop section number of cycles \ (K \) , the length of the loop section to \ (F_i \) , the remaining length \ (G_i \) , then there is \ (F_i \ K + CDOT C_i G_i = \) , this time \ (I \) contribution to the answer to \ (F_i (. 1-K) + \ min (F_i, G_i) \) .

\(40pts:\)

There is a false approach \ (n = 2 \) time is right, but the main Chen did not know why.

Consider enumeration \ (k \) . Intuition can think to make greedy \ (F_i \) maximum, i.e. \ (F_i = \ lfloor \ FRAC C_i} {K \ rfloor \) .

However \ (n> 2 \) will pan the time.

Counterexample is probably \ (k \ leq 3 \) , the greed of the \ (f_i \) the longest, because the first loop section is cut off resulting in reduced answer.

\(70pts:\)

Still have to enumerate \ (k \) , but needs to determine the \ (f_i \) optimal value.

Discuss two cases: \ (F_i <G_i \) and \ (F_i \ GEQ G_i \) .

The first case, \ (ANS F_i = \ CDOT K \) , i.e. \ (f_i <g_i \) when, \ (F_i \) larger more excellent.

At this point there \ (F_i <G_i = C_i-F_i \ CDOT K \) , transposing to give \ (F_i \ CDOT (K +. 1) <C_i \) , i.e. \ (f_i = \ lfloor \ frac {c_i} {k +1} \ rfloor \) optimal time.

The second case, \ (ANS F_i = \ CDOT (. 1-K) G_i + \) .

Consider holding \ (f_i \ geq g_i \) in the case, so that \ (. 1-f'_i F_i = \) , then \ (g'_i = c_i-f'_i \ cdot k = c_i- (f_i-1 ) \ CDOT K = G_i + K \) , are substituted into the above equation \ (ans' = (f_i- 1) \ cdot (k-1) + g_i + k = f_i \ cdot (k-1) + g_i + 1 = + 1 ANS \) .

wePleasantly surprisedWe found that \ (F_i \) decreases after, \ (ANS \) is increased. That \ (f_i \ geq g_i \) when, \ (F_i \) smaller the more excellent.

At this point there \ (F_i \ CDOT (K +. 1) \ GEQ C_i \) , i.e. \ (f_i = \ lceil \ frac {c_i} {k + 1} \ rceil \) the optimal time.

Enumeration \ (K \) , each \ (\ K) calculating two values. Complexity \ (O (\ max (C_i) \ n-CDOT) \) .

\(100pts:\)

Found for each of a number of disjoint \ ([L_i, r_i] \) , such that for any \ (K_i \ in [L_i, r_i], J \ in [. 1, n-] \) , \ (\ lfloor \ frac {c_j} {k_i + 1 } \ rfloor, \ lceil \ frac {c_j} {k_i + 1} \ rceil \) values are equal.

This inspired us to use divisible by block, for each interval counted only once.Some knowledge of number theoryKnown, such a section at most \ (O (\ sum \ sqrt {c_i}) \) a. Time complexity \ (O (n-\ CDOT \ SUM \ C_i sqrt {}) \) .


  • C

\(10pts:\)

Negated, left, right.

\(25pts:\)

Bitwise achieve a + b: xor, and, left \ (1 \) bit, can recursively.

\(40pts:\)

The added directly after every take out a maximum of iterations \ (6 \) times.

\(65pts:\)

The discovery \ (the X-\) xor \ (the y-\) extracted the highest level can be resolved.

Set \ (X \) XOR \ (Y = A \) , for \ (I \ in [. 1, \ log_2 64) \) , execute \ (A | = (A ^ 2 >> I) \) .

When doing this, \ (A \) of the highest bit less bits are all assigned to \ (1 \) . xor just fine.

\(80pts:\)

Similar practices on subtasks, you can turn directions. Card card requires a constant.

\(100pts:\)

Found necessary to achieve \ (\ min (X, Y) \) .

\ (\ min (X, Y) = [X <Y] \ CDOT X + [X \ Y GEQ] \ CDOT Y \) , multiplied by the number found necessary to achieve a \ (0/1 \) . The equivalent and \ (0/2 ^ {64} -1 \) , sub-task (4 \) \ ways to solve.

Guess you like

Origin www.cnblogs.com/suwakow/p/11375086.html