MetaOA #9
Robot Matrix Commands
估计简单可在线判题
考点(AI 标注)模拟/实现
Execute the commands swapRows r1 r2, swapColumns c1 c2, reverseRow r, reverseColumn c, and rotate90Clockwise. Indices are 0-based; a rotation turns the matrix 90 degrees clockwise and may change the number of rows and columns. Every command index is valid for the matrix at that moment. The original site's combined example had answers that did not match the commands, so this site recomputed them.
输入格式
This site's input: R C (1..100), followed by R lines each containing C integers in 0..10⁹, then q (1..100), followed by q lines of commands.
输出格式
On the first line, output the number of rows and columns of the final matrix; then output the matrix row by row, with the elements of each row separated by spaces.
样例 1
输入:
2 3
1 2 3
4 5 6
1
rotate90Clockwise
输出:
3 2
4 1
5 2
6 3
样例 2
输入:
2 2
1 2
3 4
2
swapRows 0 1
reverseColumn 1
输出:
2 2
3 2
1 4
样例 3
输入:
1 1
1
1
reverseRow 0
输出:
1 1
1
样例说明
Example 1: rotating the 2×3 matrix clockwise produces a 3×2 matrix whose three rows are 4 1, 5 2, 6 3; the new dimensions 3 2 are output first.