ZROI 19.07.30 simple string / ll

EDITORIAL: This afternoon pills ...... not a string, the whole dropped / ll


  • Given string \ (S \) , \ (Q \) times asked every given \ (A, B, C, D \) , asks \ (S [a, b] \) of all sub-strings and \ (S [c, d] \) maximum value of the longest common prefix. \ (| S |, Q \ ^. 5 Leq 10 \) .

Invert build a SAM, each half of the answer. If there are legitimate right end point of a certain string in \ ([A + len-1, b] \) , Chairman build a tree maintenance at these suffixes can not correspond in a string of sub-tree.


  • A string \ (S \) , initially empty. \ (m \) operations, each operation at the \ (x_i \) end of the string operations after no more than plus a \ (K \) character \ (C_i \) , and obtains a new shortest string cycling festival, by force. \ (m, K \ ^. 5 Leq 10 \) .

Sol1:

We found that to be maintained kmp of \ (next \) array, but the complexity of kmp is shared equally, if available, then the persistence of a multiple jump \ (next \) location will be asked many times gg.

We may consider giving it tightens it.

Set \ (trans_ {x, c} \) represents the (X \) \ added behind a character \ (C \) , will be transferred to the position.

Consider \ (trans_ {x, c} \) and \ (trans_ {next_ {x} , c} \) What is the difference.

If \ (next_ {x} \) behind the character is not \ (C \) , obviously they are equal. Otherwise \ (trans_ {X, + C} = next_x. 1 \) .

To \ (trans \) array can be persistent about, every time a position to modify.

Sol2:

The hopping \ (Next \) when, if \ (next_x \ Leq \ X FRAC} {2} {\) , can directly jump, jump up as \ (\ log \) times.

Otherwise it shows \ (x \) has a length \ (x-next_x \) cycle, regardless of how jump in the cycle, after a character is equal.

You can jump directly to \ (x ~ mod ~ (x -next_x) \) location to discover the most will jump \ (\ log \) times.

Such is the complexity of the strict.


  • Length \ (n-\) string into at least \ (K \) segment, such that all sub-strings in each section, the largest sub-string lexicographically smallest.

First-half the answer, then consider the reverse process. Each time a character is added in front of, the new SA is determined whether the substring to score more than two.


  • Given a string \ (S \) , maintaining a string Vector \ (T \) , supports three operations: \ (T.append (T_x + C) \) , \ (T.append (C + T_x) \) , asks \ (T_x \) in \ (S [l, r] \) number of occurrences. \ (| S |, m \ Leq. 5 ^ 10 \) .

Found \ (T_x \) must be \ (S \) substring, otherwise you can put it away.

For each \ (T_x \) can maintain it in the (S \) \ node positions on the SAM, the operation 1 and 2 can be done directly, offline operation 3 may be combined segment tree or tree President.


  • Interval essentially different number of sub-strings.

Offline scanning line. Consider adding a new character every time how to do.

Consider violence, suppose we joined the new SAM in character, then the substring it must be newly generated from this newly added node has been dancing \ (fa \) to jump to the root, through the road node.

Each node maintains a \ (lstpos \) , represents the last jump to the location of this node, then the left end point will have an impact on the right to ask this location.

We found that the operation of lct like \ (access \) operations, the same \ (lstpos \) can be seen as a period, is shared equally \ (\ log \) segment. Effects of each segment will produce the form of a piecewise function, only a constant segment, segment tree can be maintained.

Overall complexity \ (O (n-\ log ^ n-2) \) .


  • Interval essentially different palindromic sequence number.

He dropped, Gugu Gu.


  • String \ (A \) of \ (B \) is good if and only if \ (A \) in \ (B \) appears in at least twice. Given \ (S_1 \) , seeking the maximum \ (K \) , so that there is the character sequence \ (S_1, S_2, ..., S_k \) satisfied for an arbitrary \ (I \ in [. 1, K) \) , \ (S_ {i + 1} \) of \ (S_i \) is good.

Obviously each \ (S_i \) is \ (S_1 \) substring.

There must be a set of optimal solutions, so that for \ (I \ GEQ 2 \) , any \ (S_ {i + 1} \) are \ (S_i \) suffix.

Proved relatively Obviously, if it is not a suffix, remove the back of the suffix part does not affect the answer.

So the answer is a chain of SAM, ancestry can look at each point half.


  • Given string \ (S \) , find the longest suffix twenty-two between palindromic LCP, each time \ (S \) After the addition of a letter, after the output answer the letters, by force.

The longest palindrome LCP, is actually a palindrome LCA depth between trees twenty-two.

When adding a new letter, consider it before LCA and depth of all nodes and found that each ancestor contributions to the \ (size_x \ Times (dep_x-dep_ fa_x {}) \) , is a classic data structures, LCT can be maintained.


  • Seeking string \ (S \) all sub-strings, optionally two, satisfy \ (| A | + | B | -2LCP (A, B) \ leq L \) a \ ((A, B) \ ) number. \ (n-\ Leq. 5 ^ 10 \) . Pseudo-random string.

Significance of this stuff is actually the length of the path between two points suffix tree.

Tree divide and conquer find no longer than \ (L \) of the total number of path.

Each node of the tree heuristic merge sub suffix tree can be.

Many LCP kind of problem with a tree structure to analyze have very good results.


  • Interval Border. \ (n-, Q \ ^. 5 Leq 10 \) .

Shortest cycle into sections. Discovery loop section interval period is equivalent to find a \ (X \) , so \ (X + the LCP (L, L +. 1-X) -1 \ R & lt GEQ \) .

Scanning line running from left to right, the left endpoint encountered inquiry would be added. The first qualifying encounter for each challenge \ (i \) you can get the answer.

LCA is equal to the depth of LCP suffix tree.

LCA there are two cases: ① \ (dep_L> dep_i \) , ② \ (dep_L \ Leq dep_i \)

From the suffix tree \ (I \) node corresponding jump up, jump when a node requires subtrees and its ancestors (corresponding to the two cases) are inquiry determines whether the condition is satisfied as long as the maintenance inquiry the minimum can be, to meet the conditions for direct violence may be deleted.

Tree can be used to accelerate this process sectional complexity \ (O (n-\ log ^ 2N) \) .


Girls dropped in ......


  • Lyndon string

For string \ (S \) , if its minimum suffix itself, then it is Lyndon string. It is equivalent to cyclic shift in which a minimum.

Theorem: If \ (u, v \) is Lyndon string, \ (u + v \) is Lyndon string, if and only if \ (U <V \) .

Theorem: We can put any string uniquely divided into \ (v = v_1 ^ {q_1 } + v_2 ^ {q_2} + ... + v_k ^ {q_k} \) form satisfies \ (V_I \) is Lyndon string, and \ (V_I> V_. 1} + {I \) .

Construction: cutting out.

Back Example: also is down.

Guess you like

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