National training Day3 notes

Simple data structures

example

CF103D

\ (y \ geq \ sqrt m \) violence do when

\ (y <\ m \ sqrt ) when treated with violence

bzoj2054

Reverse process, only the last one covering an impact on the operating position

Disjoint-set to maintain each of the positions of a position uncovered

CF480E

Reverse operation, the answer is obviously not drop

A current enumeration answer \ (ANS \) , to determine whether each \ (1 + \)

\ (check (ans + 1) \) , then only need to consider the new square, that is one is certain what each grid maintenance as far as possible to the left / right number of lattice, with a \ (sliding \ windows \ ) and to check queue monotone

ZJOI2016 travelers

Consider divide and conquer

Suppose that two points of the path will be through the intermediate line (assuming longitudinal cutting). And forcing a point intermediate the path enumeration line through it, determined using Dijkstra's distance to a point at both ends of this path. Two points in time on the same side of the need to continue to divide and conquer it.

Time: \ (T (n-, m) = (n-2mlognm ^ O) + 2T (n-, \ FRAC} {2} {m) \)

Another \ (S nm = \) , each taking the longer side partition is better, then \ (T (S) = O (S \ sqrt S) + 2T (\ frac {S} {2}) = O (S \ sqrt SlogS) \)

Advanced data structures

Minute Osamu

basis

The nearest point on the plane

Sub-minimum distance rule seek left and right halves of \ (H \) , only need to consider both sides of the dividing line distance (H \) \ points within the rectangle, every time do not need to enumerate the many years when the point of check ( substantially just check \ (6 \) have around, consider a long \ (2H \) wide \ (H \) of the matrix, there is placed up \ (6 \) points such that the distance between any two of at least \ (H \) )

One Problem

On a similar theme of divide and conquer

Tree partition (dotted rule)

Gravity: all subtrees \ (size \) are \ (\ leq \ frac {n } {2} \)

bzoj1468(solved)

Template title

bzoj2599(solved)

Ibid, Note Because maintenance is the minimum can not be obtained by the inclusion-exclusion

One Problem

Cluck

cdq partition (in chronological partition)

Time of previous operation will have an impact on the operation at a later time

Dimensional partial sequence

Note \ (Z \) is the time dimension, in accordance with the \ (Z \) sort. After the partition need only consider the contribution of the left half of the right half of the direct Fenwick tree

\(T(n)=2T(\frac{n}{2})+O(nlogn)\)\(O(nlog^2n)\)

bzoj2683

The establishment of partition structure on the dimension of time, consider only the impact of the increase on the back of earlier inquiries, followed by ditto

bzoj2716

\ (ans = | x_i-x_j
| + | y_i-y_j | \) violent demolition of absolute value, ran four times cdq

Suppose \ (x_i> x_j, y_i> y_j \) , then \ (ANS = (x_i y_i +) - (+ x_j y_j) \) , each query \ (max (x_j + y_j) \) to

Overall dichotomy

POJ2104(q<=2*10^5)

Template title, slightly

LOJ2169

Ditto

Segment tree partition

bzoj4025(solved)

While the insertion side determines whether a bipartite graph: Weighted disjoint-set, the distance to each point to maintain it in the root of the subtree in the same tree plus side is determined whether a ring formed odd

For each edge there is a time \ ([L, R & lt] \) , put it into a log segment tree split segments, modified segment tree traversal manner, the process ask all leaf nodes. In this case support the need to maintain a fallback disjoint-set, if the path compression, then the time complexity would degenerate into a \ (O (the n-) \) , it can only be consolidated by rank. The total time complexity \ (O (nlog ^ 2n) \)

example

HNOI2016 network

Split the heavy chain: light edges is the number of hops up \ (O (logn) \) article (referred to \ (U \) weight son \ (V \) , then \ (siz_u> 2siz_v \) , so when the light-hop edge subtree size by at least 2)

Maintenance Delete: maintains two stacks \ (P, Q \) , where \ (P \) processing insert, \ (Q \) processing to delete, find every time you ask \ (P.top () \) and \ (Q .Top () \) , while the same pop-up (use the tree line divide and conquer to avoid using the heap, but the time complexity are \ (O (nlog ^ 3n) \)

Binary \ (MID \) , check all \ (\ geq mid \) cross-path is included \ (U \) , a single query have 3 \ (log \) time (segment tree partition + bipartite + doubling LCA)

Overall dichotomy: insert delete the path using a tree difference, by force if modifications can be converted into a single point, interval (sub-tree) query, BIT maintenance. The insertion and deletion to both sides of the divide and conquer when:

Direct dichotomy: ask if there is \ (\ geq mid \) and do not go through \ (u \) path. Segment tree \ ([l, r] \ ) Maintenance \ (\ forall w \ in [ l, r] \) cross paths

ARC093F

Suppose \ (1 \) at position 1, denoted \ (G_i = [{P_ ^ {2} + 1'd K-1}, {2 ^ P_ K}] \) , then \ (min (G_i) \ notin A \)

Inclusion and exclusion, enumeration \ (S \ in [n-] \) , there are \ (\ forall i \ in S , min (G_i) \ in A \)

\ (F [I] [S] \) : in \ (... a_i \ a_m) in, \ (S \) in (G \) \ minimum number of programs in which

Guess you like

Origin www.cnblogs.com/encodetalker/p/11620699.html