52 provincial election simulation

Figure A.

  It is actually a construction problem.

  Constructor is a positive solution to first identify any spanning tree for the non-spanning tree edge, if these edges form a bipartite graph, it can be dyed separately to both bipartite graph, and finally discuss the four colors.

  Otherwise, indicating the remaining sides there must be odd ring, then due to the presence spanning the remaining sides must be explained Unicom to find any of the odd loop and output can be.

B. the number of columns

  For subtask1, you can ask directly for each number.

  For subtask23, since the number of the small size, considering pressure level, band 100 can be engaged in a determined one of the three numbers.

  For subtask4, the number of first 16 pair off factor for each set of query ^ $ 1,10 49 $, 49 may be determined so that a number of bits.

  For the first eight we need to know the number of the other 8 bits, then so long as the number of the first packet in each group, once every four interrogation may determine a post 8, and then a solution of the group the solution, then handed the introduction of all solutions.

C. walk

  One of the original title is not difficult.

  The optimal solution must be on the way back to eat, consider a simple dp, $ f [i] [j] $ express come back when $ i $ ate a total of $ j $ minimum cost, the transfer is clear.

  It found that when the second dimension is larger when not to go back, so the number of states is really just the harmonic series, the card at the border ran directly on the line.

 

Guess you like

Origin www.cnblogs.com/hzoi-cbx/p/12548623.html