Summary: Considering that the relative position of the ants will not change, and if "turning around after meeting" is regarded as "exchanging numbers after meeting", we can also figure out which positions have ants at last. Then, we just need to determine which position is "1", and then make a pointer p to represent the current position of the ants at the first position (relative to 0), Every time an ant crosses the 0 position, p will add, subtract and subtract according to the direction of crossing read the whole passage
posted @ 2019-03-23 19:46 Ressed Reading (238) Comments (0) Recommended (0) edit
Summary: Find the sum of the k-largest value of all possible connected blocks, and consider enumerating this value: $ans= sum limits_ {i=1} ^ {W} {i sum limits_ {S} {[i is the k-largest]} $Set cnt [i] as the number of connected blocks with values>=i $ans= sum limits_ {i=1} ^ {W} {i sum limits_ {S} {[cnt [i] read the whole passage
posted @ 2019-03-10 13:00 Ressed Reading (320) Comments (0) Recommended (0) edit
Summary: Usage The nature of the heap that can be merged in log complexity. Each node has a distance. I don't know the specific definition. 1. Meet the nature of the heap. 2. Left child node distance>=right child node. 3. Node distance=right child node distance plus 1. Implement merge (x, y) according to the above properties. First select the larger of x and y (big root heap as an example), and then take its right child and another to merge, If the merge comes out, no read the whole passage
posted @ 2019-03-06 20:27 Ressed Reading (147) Comments (0) Recommended (0) edit
Summary: First, such points must be on the convex hull, and then rotate the shell. Specifically, enumerate one endpoint of the diagonal, and the other endpoint turns on the convex hull. The remaining two points are the largest and the smallest cross product. These two points also turn with each other, so they are $O (N ^ 2)$ read the whole passage
posted @ 2019-03-05 14:21 Ressed Reading (160) Comments (0) Recommended (0) edit
Summary: Let the first set be A, and the second set be B, first judge whether each B [i] can replace A [j], that is, B [i] is linearly independent of other A Let $B [i]= sum limits_ {k} {c [k] * A [k]} $, then just check whether c [j] is equal to zero, if c [j]=0, it means that B [i] can be expressed in a linear way other than A [j], so B [i] cannot replace A [j], no read the whole passage
posted @ 2019-03-05 14:10 Ressed Reading (192) Comments (0) Recommended (0) edit
Summary: Use the method of calculating the number of spanning trees to define the degree matrix A, where A [i] [i] is the degree of point i; Adjacency matrix B, B [i] [j] is the number of sides from point i to jFor an undirected graph, use A-B, then select an i at random, remove the ith row and the ith column, and its determinant is the number of spanning trees. For a directed graph, the number of outgoing trees is the degree matrix replaced by the degree matrix; The number of inward trees is replaced by the degree matrix; The deleted rows and columns must read the whole passage
posted @ 2019-01-16 14:19 Ressed Reading (179) Comments (0) Recommended (0) edit
Summary: Myskcoo's Polynomial Family Bucket Transmission Gate rvalue's FFT explains the purpose of the transmission gate, which is to quickly change the polynomial (nlogn) into the point value expression, or quickly change the point value expression back to the coefficient expression (inverse transformation), (most of the time) to achieve the purpose of convolution (for convenience, use wn to represent the root of n-th degree unit ω n) Consider selecting special points and using divide and conquer to reduce the scale of the problem. First, make up zero at the high order of the polynomial read the whole passage
posted @ 2019-01-16 14:08 Ressed Reading (308) Comments (0) Recommended (0) edit
Summary: Use to quickly ($O ( frac {n ^ {3/4}} {logn}) $) calculate the prefix sum of some functions, and (as an intermediate result) only calculate the prefix sum of prime numbers. Generally, $f (p) $is a product function, $f (p) $is a polynomial form, and $f (p ^ k) $can be quickly calculated. First, consider to find the sum of prime numbers within the range. If there is $f (p)= sum {a_i read the whole passage
posted @ 2019-01-11 20:44 Ressed Reading (532) Comments (0) Recommended (0) edit
Summary: The purpose is faster than linear ($O (n ^ { frac {2} {3}) $) to find the prefix and pre knowledge of some integrable functions: Dirichlet convolution form such as $h (n)= sum limits_ {d | n} f (d) g ( frac {n} {d}) $, then it is called $h (n)=f (x) * g (x) $If f and g are both integrable functions, then the rolled out h is also a product function, which can be proved by Dirichlet read the whole passage
posted @ 2019-01-06 12:53 Ressed Reading (189) Comments (0) Recommended (0) edit
Summary: Predecessor skill: divide and calculate in blocks, such as $ sum limits_ {i=1}^ {n}a_if The formula of ( lfloor frac {n} {i} rfloor) $can find that $ lfloor frac {n} {i} rfloor $has only $O ( sqrt {n}) $values, and i with the same value is continuous, so $O ( sqrt {n}) can be used read the whole passage
posted @ 2019-01-05 23:00 Ressed Reading (188) Comments (0) Recommended (0) edit