Do question the record before retiring (CF VP)

I can see the code on CF commit record. . (Anyway, I certainly dish so no one will look at my code ..)


1168C And Reachability

For each number of columns \ (a_i \) is obtained behind it (including itself) a first section \ (J \) bits are \ (1 \) position number, referred to as \ (nxt (i, j ) \) .

This thing can seek backwards, can be \ (nxt (nxt (i, j), k) \) Update \ (NXT (I, K) \) , the array can process the \ (O (\ log a) \) answered asked.

Time complexity is \ (O (n-\ log ^ n-2) \) .


1168D Anagram Paths

Lane said solution to a problem can engage in dynamic DP, however, does not. .

Obviously, if there are two leaf nodes of the same depth, then no solution.

Referred to the entire tree depth \ (H \) , \ (MAXCNT (X, C) \) represented by \ (X \) within the subtree rooted at all from \ (X \) departing into the chain of characters leaf node \ (c \) the maximum number of occurrences. It is Necessary and Sufficient Condition for any \ (X \ in [. 1, n-] \) , satisfies \ (\ sum_ {i = 0 } ^ {25} maxcnt (x, i) \ leq h-dep ( the X-) \) .

There is a conclusion, if all the leaf nodes of a tree of the same depth, under the premise still meet on a condition, as much as possible to delete only one son node, the depth of the resulting new tree is \ (O (\ sqrt n) \) because the nodes are not the same for each depth.

Therefore, build a new tree and the initial process \ (F \) after the array, each crawler chain modified query like violence, since it is a binary tree guaranteed time complexity as \ (O (n \ times 26 + n \ sqrt the n-) \) .


1168E Xor Permutations

The official solution to a problem is unlikely to see to understand. .

First the goo, Gugu Gu. .


1149B Three Religions

Order \ (f (i, j, k) \) represents three matched respectively to the first string \ (i, j, k \ ) when the position, a minimum value of the last position of the match in the text string. Transfer considerations, we can enumerate the last position and the text string which is the string matching, i.e., automatic machine through the sequence from \ (f (i-1, j, k), f (i, j-1, k), f (i, j, k- 1) \) transfer.

Performed while transferring the above modified like, time complexity is \ (O (Q \ ^ 2 Times 250) \) .


1149C Tree Generator™

The left parenthesis seen as \ (1 \) , seen as a right parenthesis \ (- 1 \) .

Continuous period and the answer is the opposite of the maximum plus immediately behind it a continuous period and may be used to maintain strong segment tree, the time complexity is \ (O (n + q \ log n) \) .

The official practice solution to a problem is transformed into a prefix and do.


1149D Abandoning Roads

You can find the minimum spanning tree requires us to select the edges as much right as \ (a \) side.

We consider the addition of all of the right side in the figure \ (A \) edge, this will form a plurality of FIG communication blocks. We need to find a \ (1 \) to \ (I \) path can meet through a right side of \ (B \) side, its two end points in the same block in the communication, a communication can not leave the block and then come back.

Such direct voltage +-shaped time complexity of Dijkstra \ (O (2 ^ n-2 n-^ \ n-log) \) , is clearly unacceptable.

However, we note that if a block size of Unicom \ (\ leq 3 \) , then the shortest path will not leave the communication block and come back, that we do not like pressure size \ (\ leq 3 \) of the communication block. By this conclusion we can optimize the time complexity \ (O (\ {FRAC. 1} ^ {n-2} 2. 4 ^ {\ {n-FRAC. 4} {}} \ log n-) \) .


1149E Election Promises

One idea is to set the original image is divided into several separate, independent internal set no impact, then find help \ (SG \) independent set of function division has many good properties, concrete can look at this blog post .

barley GCz

Guess you like

Origin www.cnblogs.com/ErkkiErkko/p/10950311.html