2019 Summer Jinhua training Day7 dynamic programming

Autistic training Day7

Dynamic Programming

LOJ6395

First discovered in the form of a tree with nothing, just to ensure that the sum is the degree \ (2n-2 \) , and can be greater than 0 degrees.

Then set \ (dp_ {i, j} \) represents the former \ (I \) points with the \ (J \) minimum number of degrees, and then obtain \ (O (n ^ 3) \) a DP .

Might reduce the degree of each point are 1, then the total degrees becomes \ (n-2 \) a.

Consider the original \ (i \) What role is: to limit the number of points can not choose more than \ (the n-\) .

At this point we have total degrees less than \ (the n-\) , so long as the degree is not a point of 0 degree is not more than the total n-2 points then you certainly have no more than n. So we can first consider all points of the contribution are \ (f (1) \) , then if the election is \ (k, k \ ne 1 \) then put the contribution to \ (f (k) -f ( 1) \) .

So you can directly set \ (f_i \) indicates that the current degree of and for the \ (i \) of the maximum contribution, then you can do a full backpack.

LOJ2552

Set \ (f_ {i, j} \) represents \ (I \) current left \ (J \) probability of blood, the lock is equivalent to a transfer of skills.

Then the last inquiry is gone, very simple.

Then ask it every time? Our concern is just the first \ (i \) the probability of personal survival, is set to \ (P_i \) .

Then everyone will be hit by the probability of it? Set \ (g_j \) said that apart from myself there \ (j \) the probability of personal survival, is to find a backpack, directly on the hard partition FFT can get 70 points.

Of course, we can put a whole backpack calculated again to return the current article, it \ (O (Cn ^ 2) \) a.

CF53E

Inclusion and exclusion, seeking at least (k \) \ number of leaves program.

Enumeration leaf collection, with the remaining set of points spanning tree, and the leaf hung back, complexity \ (O (NN ^ 2 ^. 3) \) .

FMT then optimized with the inclusion-exclusion, no more.

UOJ129

Found satisfying \ (x ^ 2 \ le 500 \) primes only 8.

Thus each number only have these primes as another large prime factor.

The number of all sorted by large prime numbers, then it must be placed in a continuous period of the same set (or not selected).

Then set \ (f_ {i, S, T} \) represents the former \ (I \) th, \ (S, T \) inside which are primes, to mess DP.

A title

Some selected positions, so that these positions are not adjacent. Adjacent is defined as eight connectivity.

Problem solution is plug DP.

(How did hear the question, but probably not difficult)

UOJ266

Deleted after the discovery of one strand bound to turn into several sub-tree, so you can set up \ (f_x \) represents \ (the X-\) sg subtree function values, which point in the tree and then delete the sub-enumeration of violence, gained the polynomial time algorithm, it should be \ (O (n ^ 2) \) a.

How to optimize?

Set \ (g_x \) represents \ (x \) and his son \ (f \) XOR value, and then found a deleted chain is this chain of \ (g \) XOR value and then XOR swap roots. (Probably means that this might presentation is not very clear)

So within the sub-tree maintenance support the insertion of a dictionary tree, global XOR, seeking mex, merged, gone.

NTF readily cut off Qinghua training title, NTF into the Tsinghua University, NTFAKIOI! ! ! !

A title

Plane \ (2N \) balls (pairwise different position of the ball), there are \ (2N \) a robot located \ ((0, I), (I, 0) \) , each activation of a robot take it axes perpendicular to the direction of the nearest ball, and asked how many methods to take away all the balls.

The treated as each row, each column of a point, a ball as a side, the right side is \ (the y-the X-+ \) , then activate the first \ (i \) point line when it will take away with him together the smallest edge right side column empathy.

It is possible to know that each block of the communication points is equal to the number of edges, that is, a group to the ring two trees. Exactly one point to be selected from each side, and by a method selected from the above limitations sides, and then find the number of such a sequence of the selected edge.

Click on each side of the tree is determined (to his own father that edge), but there are two cases on the ring, so the first enumeration which is the case, then each point to choose sides determined.

In a tree, watching his son to choose a side edge of the size of the right side of the relationship they have to choose and, if it must be before the election than their small, all the way up the DP.

In the ring to see if their relationship is about the size of the two sides, if they have to choose the right side then you have another point bigger than themselves before the election, to form a relationship of some less-than sign, but also count the number of combinations to use Gone.

AGC007D

Set \ (dp_ {i} \) represents the former feed the \ (I \) a bear, and the current position of the first \ (I \) a bear there, the minimum time.

Then the enumeration time, there are two situations: either go directly back to wait to go back there.

Apparently monotonous queue can optimize gone.

bzoj2216

Decision-monotonic, we will.

Quadrilateral inequality

If for any \ (i_1 \ Le i_2 are used \ Le j_1 \ Le J_2 \) , both
\ [w (i_1, j_2) + w (i_2, j_1) \ ge w (i_1, j_1) + w (i_2, j_2) \]
then meet decision-monotonic.

LOJ566

Median enumeration \ (W \) , the one side is split into two: \ (a_i-W, W-a_i \) (black bars are white), then both plus \ (W \) , becomes \ (a_i-2W, a_i \) , then the required one is exactly \ (n / 2 \) strip of white side maximum spanning tree.

This can be obtained directly wqs two points, thereby obtaining the \ (O (m ^ 2 \ log ^ 2 m) \) approach.

Then one conclusion: For optimal \ (W \) , the spanning tree contains only \ (a_i \ ge w \) of black bars and \ (a_i \ le w \) white edge. (???)

Consider wqs binary process, is to make \ (2w-a_i \) becomes \ (2w + k-a_i \) , we found this way may not enumerate \ (W \) directly bipartite \ (2w + k \) , and then gone.

(???)

The cushions

LOJ565

We found that the number of carry less of a 1 1.

Thus the subject is converted into the desired final number of request 1.

So the answer has nothing to do with the order of operations.

For each one, seeking its contribution.

Previous from DP, denoted \ (dp_ {i, j} \) represents the \ (I \) bit count Bit motivated the stack \ (J \) probability 1s.

There are two transfer. A carry is made from the one is \ ({dp_. 1-I, J} \ rightarrow dp_ {I, J / 2} \) ; a is in the operating position, corresponding to multiplication \ (px + 1 -x \) polynomial.

DP is the direct violence \ (O (n ^ 2) \) a.

Multiply polynomials can find partition FFT, and a position if the increase \ (w \) you can only go-ahead \ (\ log_2 w \) positions, so each location can handle only where there is a maximum value, and then can permit the complexity is \ (O (n \ log ^ 2 n) \) a.

Guess you like

Origin www.cnblogs.com/p-b-p-b/p/11305280.html