ZROI 19.08.12 simulation game

Portal

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


"I found the root of the problem is that we are not the prefix and." - London Lord


  • A

London Lord spj wrong, almost konjac swk away

\(50pts:\)

Consider how programs do not output. Apparently the tree dp.

Set \ (f_ {i, j, \ {0/1/2 \}} \) represents \ (I \) subtree, there \ (J \) chains, the root node state: \ (\ { \) is not selected from the group \ (/ \) is selected from the strand downwardly \ (/ \) selected from the two chains downward \ (\} \) is the optimal solution.

For a sub-tree, considering only the root node at the beginning of each turn merge son. When you merge state need to enumerate the father and son, with \ (size \) limit the upper bound of enumeration, it can prove complexity is \ (O (nk) \) is.

When transferred to discuss transfer between respective states.

\(100pts:\)

Output program is not difficult, just need to record each state can turn to the state from which the transfer of which his son.

It can be transferred on the direction of his son, avoiding complex can be persistent.

Of course, to write is another matter

Complexity Proof:

The combined size are \ (x, y \) of two subtrees, complexity \ (O (\ min (X, K) \ CDOT \ min (Y, K)) \) .

May assume \ (GEQ X Y \ \) , where two of the three sub-tree analysis, respectively.

\ (X \ GEQ K, Y \ GEQ K \) , the single-complexity \ (O (K ^ 2) \) , but this subtree up \ (\ frac {n} { k} \) trees The total complexity \ (O (NK) \) .

\ (X \ GEQ K, Y <K \) , each node up to find that the combined intake \ (size \ geq k \) of a subtree, i.e. up to produce whole grain each tree node fragmented \ (O (k ) \) the complexity of the overall complexity of the \ (O (NK) \) .

\ (X <K, Y <K \) , for a node with at most \ (O (k) \) after the merger of nodes, the size of the subtrees will \ (\ geq k \) up, so that each node generating \ (O (k) \) complexity, overall complexity \ (O (NK) \) .


  • B

\(60pts:\)

For one operation \ ([X, Y] \) , the interval \ ([l_i, r_i] \ ) Sufficient Conditions be accessed is: \ ([X, Y] \) and \ ([l_i, r_i] \ ) there post; \ ([X, Y] \) is not completely contained \ ([l_i, r_i] \ ) of the father.

You can get a \ (O (nq) \) algorithm, that is, for each node of the tree line, respectively, statistics visits. There are many categories discussing implementation is more complex.

\(100pts:\)

For \ (O (nq) \) algorithm in classification discussion, each discussion actually can extract about (x, y \) \ low-order polynomial.

Found that if the interval \ ([l_i, r_i] \ ) is \ ([x, y] \ ) comprise, for each subinterval of it which are contained. Therefore, the entire sub-tree may avoid classification discussion, pretreatment polynomial coefficients can be.

Node may be completely contained encounters exit interrogation i.e., equivalent to the complexity of the query tree line interval, \ (O (n-Q + \ log n-) \) .


  • C

\(60pts:\)

Found \ (h_ {i + 1} -h_i \) is equal to \ (I \) for each end position of the sub-string \ (G_i \) sum, i.e. \ ([1, i] \ ) added at the end of each prefix a character.

The \ (n \) suffix pulled out run kmp, and to maintain what prefix.

\(100pts:\)

For string \ (A \) , \ (F_i \) meaning actually \ (A [... I. 1] \) border number (equal to the prefix and suffix).

Whereby \ (G_A \) is the meaning of \ (A \) number of occurrence of each prefix \ (- 1 \) sum, because each enumerated prefix to a location outside the first time, will be generating a border contributions.

Consider \ (H_ {I}. 1 -h_i + \) , i.e., \ (\ sum_ {j = 1 } ^ i G_ {S [j ... i]} \) significance was found for the \ (S [1 ... i ] \) for each sub-string, which is provided for the number of occurrences \ (D \) , the contribution to the generated \ (\ FRAC {D (. 1-D)} 2 \) .

Maintenance suffix automaton, each time a new character is added, equivalent to \ (Fail \) tree to the root node chain \ (1 + \) , or offline sectional LCT tree maintenance.

Guess you like

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