AGC039

Contest Page

A

sol For a same character segments of length L $ $, apparently spend $ \ frac {L} {2} $ operations adjacent to such different. So just talk about classification and last characters are the same, each character is calculated, the length of each segment of consecutive characters appear how many times.

B

sol First, when the graph is not bipartite graph is certainly no solution, otherwise the answer can be found on the border of two points on the map is the shortest maximum, and construction is not difficult to reach an answer out of bounds on the program. Thus bfs / Floyd this value can be determined.

C

sol It can be converted into a title: Every time the minimum number of bits of the exclusive $ 1 $ or placed on the highest level, ask how many times it can be the same as the original number. It would appear that every number after $ 2N $ times will return to the original number. So what number of operands less than $ 2N $? Hand play can be found: a number can be expressed as $ AA'AA '... $ cyclic structure A, wherein $ A $ 01 $ string is $, $ A' $ string which is the exclusive OR of all bits $ 1 $ obtained. This number only $ 2 | A | $ operations. Note that if the number of segments divided into odd, otherwise still need $ 2N $ operations.

Enumeration length $ A $ $ $ L to calculate how many cycles string section length is a number of from about $ L $. Because $ A $ string is determined to determine, at the same time corresponds to a higher bit string enumeration, it requires at most one string is determined whether or less $ S $. Finally, the inclusion-exclusion count how many cycles string section happens to be $ l $. Complexity $ O (Nd (N)) $.

D

sol For three points on a circle $ A, B, C $, taking the arc $ AB, BC, AC $ midpoint $ D, E, F $, the circumferential angle can be demonstrated by Theorem $ \ Delta DEF $ orthocenter and $ \ Delta ABC $ coincide heart.

Consider $ \ Delta DEF $, Euler line, because $ \ Delta DEF $ circumcenter is $ O (0,0) $, the center of gravity is $ (\ frac {x_D + x_E + x_F} {3}, \ frac { y_D + y_E + y_F} {3 }) $, so orthocenter is $ (x_D + x_E + x_F, y_D + y_E + y_F) $, so $ D, E, F $ contribution of three separate points. Enumeration $ AB $, consider the contribution of its two arcs of the midpoint of the answer.

E

sol A first enumeration point $ i $, $ (1, i) $ connected edges. The question then is $ [2, i) \ cup (i, 2N] $ linked to each other point in the side of the issue.

Consider $ I $ points across the edge, they have their end points monotonic, i.e., left when the part number is incremented, decremented right part number. $ I $ enumeration across the intersection point of the left half of the minimum number of edges $ (j, k) $, then the remaining points, and either the first $ $ J, or first with $ i $ intersect, or intersect with the first $ k $, and so on a number of points in each distribution period of range. point enumeration and $ j $ intersects the largest number $ p $, $ intersect $ k point largest number $ q $, then may each recursively to $ [2, j) \ cup (j, p] $, $ [p + 1, i) \ cup (i, q-1] $, $ [q, k) \ cup ( k, 2N] $ of three sub-problems.

credited with search implemented calculation, although the number of states $ O (N ^ 3) $ but not more useful to state complexity $ O (N ^ 7 ) $.

F

sol Consider a simple DP: set $ f_ {i, j, k } $ $ A $ denotes the matrix with a row $ $ $ I $ J columns minimum $ \ number of programs leq k $. Noting $ N, M, K \ leq 100 $, but such a state transition at the same time inevitably to enumerate $ i, j $ increments, since they are in effect on the $ A $, so the transfer the position has to pay.

Conversion to make a small problem that can be found corresponds to the extra weight of a filled matrix $ B $ $ B $ meet each position less $ A $ position corresponding to the minimum of the ranks, then the equivalent weights $ B $ the number of programs. $ B $ found to be equivalent to the limit line is less than the maximum $ B $ $ A $ corresponding to the minimum value of the ranks.

In this case we have two matrices $ A, B $, consider the state put on a place on a $ A $ $ B $: set $ f_ {i, j, k } $ denotes the $ A $ I $ $ column $ \ leq k $, $ B $ J $ $ in row $ \ leq k $ a $ a, B $ Total fill matrix method.

If a line is determined as the maximum value of $ B $ $ k + 1 $, then the matrix row corresponding to the determined position of the column $ A $ minimum number can be filled $ \ geq k + 1 $ a; $ B $ matrix not determined on the corresponding row can be filled column position of the minimum number of $ \ leq k + 1 $, and to ensure that there is at least one filling position $ k + 1 $;

if it is determined in a column $ a $ minimum of $ k + $ 1, $ a $ the corresponding column of the matrix determines the position of the maximum value can be filled number $ \ geq k + 1 $, and at least one filling location $ 1 + $ K; matrix column corresponding to $ B $ not determined position of the maximum value can fill several $ \ leq k + 1 $ the.

It can be found between $ A, B $ fill two matrices are non-post, so the transfer of both these two stages can be considered. Pre-transfer coefficient, complexity $ O (NMK (N + M )) $

Guess you like

Origin www.cnblogs.com/Itst/p/11706719.html