Sorting NOIP2008 dual stack (+ bipartite graph coloring greedy analog)

Portal

First consider if there is only one stack, which situation is not legal.

We will see in this case it is not legitimate, because that will be in front of the middle of the high against.

If this is the case, then the middle and that number can not put a number in front of the stack.

A minimum suffix may be pretreated, such judgment i, j, and then to see if the bipartite graph coloring contradict.

If not contradictory, then we need to output how.

Because the lexicographically minimum requirements, you can use the first stack to try to use the first stack.

The current can not be popped they would not be popped.

It is already the current sequence of a number of re-popped.

Guess you like

Origin www.cnblogs.com/yyys-/p/11845083.html