#P1205. [USACO1.2] 方块转换 Transformations
[USACO1.2] 方块转换 Transformations
Description
A black-and-white pattern on an square of tiles is to be transformed into a new square pattern. Write a program to find the minimal method to convert the original pattern into the new one using the following transformations:
- Rotate : Rotate the pattern clockwise.
- Rotate : Rotate the pattern clockwise.
- Rotate : Rotate the pattern clockwise.
- Reflect: Flip the pattern horizontally (mirror over the central vertical line).
- Combination: First reflect horizontally, then apply one of the transformations in .
- No change: The original pattern is unchanged.
- Invalid transformation: The new pattern cannot be obtained by the above methods.
If more than one method works, choose the one with the smallest index.
Use exactly one of the above steps to accomplish this transformation.
Input Format
The first line contains a positive integer .
Then follow lines, each containing characters, all @ or -, representing the initial square.
Then follow another lines, each containing characters, all @ or -, representing the target square.
Output Format
A single line containing a number between (as described above) indicating the transformation method required to convert the original square into the target square.
3
@-@
---
@@-
@-@
@--
--@
1
Hint
Constraints
For of the testdata, .
Problem translation from NOCOW.
USACO Training Section 1.2.
Translated by ChatGPT 5
京公网安备 11011102002149号