SDOI2019 Round2 do title notes

This guy has been a ghost for a long time ...... cushions

SDOIR2 topic really fun ~

Quick Query (???)

Not difficult to find all of the operations can be achieved range by playing Tag

You can maintain a two markers \ (a, b \) represents the sequence number of \ (X \) values actually represents the \ (AX + B \) . For a single point of the value assignment \ (X \) becomes \ ((xb) a ^ { - 1} \) placed inside the array, for an array of global assignment directly emptied. Only in the last empty emptying time to be changed between the empty position on the array, the complexity will not be emptied greater than the number of operations of all the foregoing operations, the complexity is right.

As for how to keep the array can also be discrete, like me, it was spent handwritten hash table

Code

Staining (DP)

Clearly there is a violence: Let \ (f_ {i, j, k} \) shows a front fill (I \) \ th column, \ (I \) color elements are two columns \ (j, k \ ) the number of programs. The complexity of the three parties do not have a minute ......

Consider squeeze out a one-dimensional in this state DP. Note that if we say there is at least one position colored column columns is important, so if we can pre-transfer between the important and significant column column, we only need to record the important column last \ (0 \) at the position can fill color, then the complexity of the DP becomes \ (O (^ n-2) \) .

I feel very good, we might consider the state between two important columns. Set \ (x, y \) is an important color column, another important consideration of the color of the column, the following situations. In the following description, by \ (? \) Represents does not \ (x, y \) of the same color, a plurality of horizontal matrix representation of these matrices is the number of programs same.

\(\left(\begin{align*} x && ... && y \\ y && ... && x \end{align*}\right)\)

\(\left(\begin{align*} x && ... && x \\ y && ... && y \end{align*}\right)\)

\(\left(\begin{align*} x && ... && ? \\ y && ... && x \end{align*}\right)\) or \(\left(\begin{align*} x && ... && y \\ y && ... && ? \end{align*}\right)\)

\(\left(\begin{align*} x && ... && ? \\ y && ... && y \end{align*}\right)\) or \(\left(\begin{align*} x && ... && x \\ y && ... && ? \end{align*}\right)\)

\(\left(\begin{align*} x && ... && ? \\ y && ... && ? \end{align*}\right)\)

Set \ (g_ {i, 0/ 1/2/3/4} \) represents the whole of the five intermediate state \ (0 \) is the number of columns \ (I \) the number of filling scheme, the transfer enumeration Finally, a whole is \ (0 \) column can be, coefficient bit complicated, you can use matrix optimizationBut I am so mindless people must be vigorously write direct expression ah

Then remove the head and tail of the whole \ (0 \) column (because their number of programs can contribute directly to the answer in), we can enumerate once every two, using the above obtained \ (g \) array transferred . Complexity \ (O (n ^ 2) \) by 96pts.

So last 4ptsOf course it is to play tableConsider optimizing DP.

When you write a formula can be found: in which all the operations a little transformation can be changed to "Quick Search" in the plus range, interval multiplication, modify single point, single point of inquiry, and ask all of the operations. You do not need to write it again quickly discrete inquiries coupled with the DP on it.

96pts 100pts

World Map (minimum spanning tree virtual)

Request a minimum spanning tree prefix and a suffix, we can first pre-spanning well prefixes and suffixes, and then consider the impact side of the connection between the prefix and suffix.

If you already have a prefix and suffix edge connector, so if adding prefixes and suffixes side of a connection, be sure to delete the two longitude \ (1 \) maximum right side of the path prefix of points on the minimum spanning tree side, or both longitude \ (m \) side of the right side of the maximum point on the path of the minimum spanning tree of suffixes. It can be found to be useful on the prefix and suffix MST MST side only longitude \ (1 \) and \ (m \) virtual tree edge point.

So we pretreatment suffix MST also use the same method, After computing the point on the MST MST on both sides of the imaginary boundary tree record, the right side edge of a note virtual tree may be directly assigned to the two point corresponds to the maximum edge weights of all edges in the MST path, the number of active edges so a the MST is \ (O (n) \) level, each time the combined complexity is \ (O (nlogn) \) .

Then you do so can get a \ (O ((m + q ) nlogn) \) approach.

Code

Noisy party and embarrassment party (construction)

Provided corresponding to the title \ ((p + 1) ( q + 1) \ geq n \)

Consider configured by: a minimum degree of each node and deleting its edge connected graph in FIG until empty, the sequence of points is provided by deleting every \ (p_1, p_2, ..., p_k \) each point is omitted when the degree to \ (D_1, d_2, ..., d_k \) , then the party on Sunday invited \ (p_1, P_2, ..., p_k \) , Saturday the party will invite \ (D_i \) all points on the maximum value corresponding to the time taken to FIG.

Proof: sequence \ (P \) all points apparent independence, \ (D_i \) lively for all selected points when the maximum value is taken to \ (\ max D_i \) . Since \ (\ SUM \ limits_. 1} ^ {I = K (+ D_i. 1) = n-\) , \ (K (\ + max D_i. 1) \ GEQ \ SUM \ limits_. 1} ^ {I = K + 1'd D_i n-= \) , so \ ((. 1 + K) (\ + max D_i. 1) \ n-GEQ. 1 + \) , so this option is valid.

Delete points using the set maintenance on it.

Code

Moving coins (step Nim, DP)

The section \ (I \) coins and \ (i + 1 \) space between the number of coins considered \ (mi The \) Section stones step number, then this is clearly a step of Nim, effective stone is stone odd festival, and the formula has no effect on the even-numbered sections of the outcome.

Therefore, we need only consider the stone odd section, assigned to direct the even number of combinations of stones section. Probability of winning the upper hand does not seem to be considered good, but better count of the number of programs is losing the upper hand, because it means that the odd stone ladder section and is exclusive or \ (0 \) , which is exactly appear every even number times. Found \ (n \) is not great, we can directly place by backpack. Complexity is \ (O (mnlogn) \) , but the actual run very fast.

Code

Contiguous subsequence (memory search)

Find the nearest provincial election is very fond of thinking of a title search (TJOID2T3 is next door, ZJOID1T1 may also be considered)

There is a similar prior \ (0110 \) shrunk \ (0 \) , \ (1001 \) shrunk \ (1 \) method, but it seems difficult to avoid re-count, and then found that there is a better approach ... ...

A property considered TM sequences, reference may OEIS A010060: make an initial sequence \ (0 \) , followed by \ (01 \) instead of \ (0 \) , \ (10 \) instead of \ (1 \) , do unlimited TM sequence times can be obtained.

So if a sequence is a subsequence TM sequence, it will, through \ (01 \) filled \ (0 \) , \ (10 \) filled \ (1 \) reduction mode is \ (0 \) .

So we consider dfs (s, k) represents the current prefix s, later also need to fill several programs k characters, the transfer can be considered enumerate filled way: There may be a s \ (x (2 \ not \ mid x ) \) and \ (x + 1 \) character combination, there may be \ (x (2 \ mid x ) \) and \ (x + 1 \) character combination, i.e., in front with a character such that \ (S [1] \) is possible with this combination of characters, a single character to be filled.

Difficult to find when the length of a string \ (> 3 \) when this division is the only way to prove that might be assumed that the two padding methods are established, then if the filling is filled in a first embodiment a prefix \ ( 00 \) or \ (11 \) , it will fill out in the second filling mode prefix \ (000 \) or \ (111 \) , which is illegal; and if filled out \ (01 \ ) or \ (10 \) , then the existence of a legitimate string impossible to meet the conditions in the second filling mode.

When the string length \ (\ leq 3 \) when, for example, the string \ (010 \) , it can be filled \ (01 | 01 \) or \ (10 | 10 \) , these two programs are legitimate but this string can only be counted once, so these places need special sentence.

Note that when \ (| s | = 1 \ ) when only a few programs and \ (k \) related to the size, in which case we can enter another layer of recursion. In this layer of recursion in memory of, then the total number of states that \ (O (logk) \) levels, while the total number of recursive solve function is \ (O (| S |) \) levels, the complexity of the very little by this question.

Code

Guess you like

Origin www.cnblogs.com/Itst/p/10991758.html