HNOI2019 problem solution

Polygon

Termination state must first know that all sides are pointing \ (n-\) number of nodes.
So if every step we make \ (n \) degree +1 it must be the best, obviously can be done.
Then from the \ (n-\) dividing a plurality of adjacent sides separate parts Solution.
For one part, every time we must be selected from a top edge \ (\ text Rotate} {\) , and then divided into two separate parts.
Note that this forms a binary tree structure.
The topological order counts forest \ (res = {n! \ Over \ prod size_i} \) answers with only tree nodes \ (size_i \) related, can be directly calculated.
Consider \ (\ text {rotate} \ ) once affected, according to the following chart:
1RgBsf.png
Only \ (x \) this point \ (size \) changes, you can update the look.

White Rabbit Dance

First, two known point value after the array corresponds to a cyclic convolution by multiplying DFT IDFT back again.
\ [C_i = \ sum_ {j = 0} ^ {n-1} \ sum_ {k = 0} ^ {n-1} a_jb_k [j + k = i \ mod n] \\ = {1 \ over n} \ sum_ {j = 0} ^ {n-1} \ sum_ {k = 0} ^ {n-1} a_jb_k \ sum_ {d = 0} ^ {n-1} w ^ {d (j + ki)} \\ = {1 \ over n}
\ sum_ {d = 0} ^ {n-1} w ^ {- di} a (w ^ d) B (w ^ d) \] consider an array DFT operator
\ [ f_i = A (w ^ i) = \ sum_ {j = 0} ^ {n-1} a_jw ^ {ij} \\ = \ sum_ {j = 0} ^ {n-1} a_jw ^ {{i + j \ the Choose 2} - {I \ the Choose 2} - {J \ the Choose 2}} \]
MTT to.
Consider considered an array of IDFT, reverse process can be.

fish

Fish and fish are two separate parts, separate and made out pretreatment.

Consider for \ (the AD \) Statistics \ (the BC \) , can first enumerate all \ (the BC \) hang it \ (the BC \) perpendicular bisector of the line segment and \ (the AD \) in a straight line \ (the AD \) corresponding to \ (\ text {vector} \ ) inside the half interval.
Perpendicular bisectors condition is necessary and sufficient for convenience with the slope-intercept \ (y = kx + b \ ) to indicate a straight line, tuple \ ((k, b) \ ) fraction are simplification (this question accuracy serious card, card int64 overflow).
For \ (y_p \ neq y_q \) of points, the slope of the perpendicular bisector lines exist, the abscissa is inserted into the vector midpoint;
for \ (y_p = y_q \) of points, the slope of the perpendicular bisector of the absence, uniquely determined by abscissa \ (x_p + x_q \ over 2 \) represents the linear type, the midpoint of the vector insert ordinate.

Consider for \ (AD \) statistics \ (EF \) , considered the first enumeration \ (D \) and then enumerate \ (A \) , then, then all points on (D \) \ point polar angle ordering, \ (\ angle ADQ \ in (0.5 \ pi , 1.5 \ pi) \) a \ (Q \) can be used as \ (E / F \) point.
Double pointer scanning, similar MO to maintain the same team for the next target distance map can be calculated on the number of points.

Enumeration \ (A \) , \ (D \) to \ (BC \) program with \ (EF \) program can take up as ordered, finally, take the \ (4 \) .

sequence

Campus Travel

JOJO

Guess you like

Origin www.cnblogs.com/bestwyj/p/12283633.html