7.25 NOIP analog 8

The state exam in front was okay, after two hours is really hard to describe, called T3, n ^ 2 violent force on the ignorant, and do not know how to optimize.

T1. Match

  Do not understand the problems found while watching (this is not a difficult test ah), and then come back after the water had finished T2 5 Fenzhong water, very pleasant a question.

  Beginning kmp want to play, then found kmp seems almost forgotten, YY on the topic should not be insane to card hash, then hit go up.

T2. Home

  A very bare tarjan, thought how crazy code after seeking to cut the number of points on a chain, started to think dfs on the line, hand prints all-too few examples, and then threw a look at T3.

  T3 violent kick back made the point, hack off! And there are about a half hour ended, I was scared a bit dfs seeking father each point, rising violence from n to 1, A steadily away.

T3. Sushi

  Probably there are two questions before the code finished 2.5h, then stared at it lost in thought, YY for a long time did not come up with less than n ^ 2 practice, the key is that I hit n ^ 2 is greedy. . . Then firmly WA to 5 minutes. The last two hours if not corrected T2, the actual score only five.

  Positive solutions is to optimize ^ n 2, a first sequence for a ring formed disconnection, optimal decision to move to the sides of one of the colors (apparently), and starting from a point of demarcation, the left toward the leftmost, i to the right of the rightmost. Then a very magical nature, the location of this cut-off point is determined! The demarcation point in a certain average position of another color. Therefore, we can half this position, the total complexity of O (Tnlogn), the title data can be over.

  In fact, we can find the position of the demarcation point is monotonic and therefore in the open position when the ring moves, simply move the pointer to the demarcation point in the same direction, the total complexity of O (Tn).

Guess you like

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