Statement
This is a heuristic optimization problem.
You are given a colored board , a stamp , and a target board . Colors are integers from to . Color is treated exactly like every other color.
Coordinates are zero-based, with at the top left. Row indices increase downwards and column indices increase to the right.
Each operation consists of the following steps.
- Choose the top-left corner of a region and .
The stamp must fit inside the board. Regions may overlap, and the same region may be used repeatedly. Moving and rotating the stamp do not cost additional operations. The rotation in each operation is relative to the reference orientation, not to the previous operation.
The position inside the selected region corresponding to stamp cell is defined by
For every stamp cell with , exchange with .
Perform at most operations to maximize the number of cells whose final color agrees with . The target does not change. Intermediate boards and the final stamp do not contribute to the score. You may perform zero operations. A perfect match is not guaranteed to be possible.
Scoring
Let be the number of matching cells on the final board. This input earns points. Your total is the sum over 40 evaluation inputs, with a maximum of points. Invalid output or a resource-limit failure earns zero for that input only. Scores do not depend on other contestants or any reference solution. Equal totals share the same rank.
Replay tool
Input
Each input file contains one instance in the following format.
Output
Print the operation count , followed by each operation in order.
Constraints
- .
- , .
Subtasks
Samples
The number of matching cells changes from to to . This output earns points.