Topic
is also a problem, unfortunately did not find this is a water problem, by the momentum of the Matrix was frightened, in fact, later made out of a lot of people, it should be thought that not so difficult. (two teammates into DP can not extricate themselves, do not want to change the plan).
Test instructions: Tells the initial matrix, the goal matrix, tells N steps (l column h row), then constructs the order, causes the change from the initial matrix to the goal matrix to be successful, the topic guarantees must have the solution (has the multi-solution, SPJ);
Analysis: The initial matrix is not useful (there is such a good hint on the field, more pity)
Initial matrix: Destination matrix: Three operations:
3 3 3 2 1 3 L 2 1 H 3 2
3 3 3 2 1 3 L 1 2
3 3 3 2 2 2
Backward push: Look at the destination matrix, the 1th and 3rd lines must be changed from one row or column, or three columns, three rows is possible, but there is no such option in the operation. That is, L 1 2 and H 3 2, ranked at the end, and then labeled the two rows of elements 0, because what was previously irrelevant, and eventually changed to 2 has been.
0 1 3
0 1 3
0 0 0
You can then find that the 2nd column can be considered to be all 1, exactly L 2 1.
Because there must be a solution, the others do not consider. Can traverse all operations 100 * 100 * 500 will not time out, this topic is a pity really ....
HDU 5386 Violence