CSP - S 2019 brief explanations

Finished the solution to a problem or to write about.

Day1

T1 - Gray code

Determine the highest and press that Italy can recursively to sub-problems. Note that open unsigned long long.

T2 - brackets tree

Apparently the only requirement is that we go from the current node to the root of the shortest sequence can be legitimate in parentheses. If the current character ), then the path must not legitimate, and vice versa, provided \ (f [x] \) represents the number of the current path to the root of the number of left and right bracket bracket Save current node to the last occurrence of \ (F [ x] \) must be the shortest sequence legitimate brackets. Open barrel record, and can be revoked at the end of dfs.

T3 - Number of trees

Because demand is dictionary order, we can consider in order to determine the minimum number of fill. Consider the final \ (X \) from \ (A \) come \ (B \) , for the entire impact is actually the result for each node on the path, the adjacent side of the operation sequence has joined a restriction . Limiting form: one immediately after the other side must be operated one side, or a side should be the first / last operation.

With disjoint-set to maintain current location, turn dfs, violence can do to determine whether a node. Of course disjoint-set maintenance order each segment can be replaced directly determined first / last edge, but did not get better complexity (both \ (O (^ n-2) \) ).

Day2

T1 - Emiya family meal today

Consider have at most one position is not satisfied (\ lfloor n / 2 \ rfloor \) \ conditions, and transformed what is actually selected this location than the other and even more.

Enumerate what a location, choose the number of recorded what difference do dp.

T2 - divided

It will not prove.

Emotional understanding / play table / pretend he was right, find a location for each greedy closest election is correct.

\ (n \ log n \) is very simple, violence contribution of each position can be half the interval.

Linear approach can use a monotonically queue / stack monotone / xxx monotone maintenance.

Finally, to add precision.

T3 - brackets tree

Currently not linear approach.

Statistics for each point of which is the focus of several programs.

Each of the enumeration, each side there is a limit to the current point subtree rooted size (the interval period).

Cool analysis, we found query can be converted to (1 point to the root sequence dfs subtree size) two-dimensional point number, or the current point interval query to root One point.

Inquiry chairman offline Fenwick tree or tree can be directly done \ (O (the n-\ the n-log) \) .

Guess you like

Origin www.cnblogs.com/weiyanpeng/p/11914004.html