6 analog solution to a problem

A. That day we promised convention

After simple dp written complexity is $ O (nmd) $, we consider optimization.

Broad range D in question and the N M,

We are in the process of dp's, the number of days a lot of cookies are not to be invalid day.

So we dp embodiment the number of n finished biscuit with an effective talent of i,

I is then put valid days days can be assigned to d.

$ans= \sum \limits_{i=1}^{n} dp(i,0)* \binom{d}{i} $

 

 

 

B. That day she left me

 Violence ideas 1: Process evaluation function, dfs with the shortest.

      $Accepted$

Violence ideas 2: Each side is connected to enumerate the starting point and delete, respectively, run the shortest try to update the answer.

      $Accepted$

Violence idea 3: The starting point for all sides and connected to delete, from the point went shortest connecting point is connected to other attempts to update the answer.

      $Accepted$

Correct answer:

3 try to optimize violent ideas.

This algorithm has found part of the redundancy, we can be grouped shortest path.

Because any two different points, there must be at least a different binary.

We are grouped with each binary bits 0, 1,

Each of rings of points must be updated at least once, then can be attained.

Complexity $ (m log ^ 2n) O $

$Accepted$

 

C. one day she can come back to me

Consider the meaning of the questions into a diagram.

That is, we will reverse side of each card corresponds to the front edge digital construction.

Our goals into:

Flip seeking minimum number of edges, each of the points is not greater than 1, and calculates the number of programs.

dp can be.

For each block Unicom:

Let n points, m is the number of edges.

1 is a block Unicom tree, i.e.

$m=n-1$

As the root node at any point, to try to make the point of the addition of a root node, the root of this time to obtain the minimum number of turns.

In other root dp, can be obtained as the number of other points of inversion of the root node.

2 is a block Unicom tree ring, i.e.,

$m=n$

Social ring is ring a certain tree tree, trying to make the point on the ring clockwise or counterclockwise,

Ring does not directly point to the tree dp.

3. Unicom is impossible for each block of the dot is not greater than 1, i.e.,

$m>n$

Directly out cycle, output no solution.

Eventually we flip the minimum number is the smallest number of flip each Unicom block sum,

Program number corresponding to each block is minimum Unicom logarithmically program product.

Guess you like

Origin www.cnblogs.com/skyh/p/11220702.html