Capital OneOA #3
Robot Matrix Commands
估计中等可在线判题
考点(AI 标注)模拟/实现原地数组
Execute row/column swaps, reversals, and clockwise rotations in order. Coordinates use 0-based indices.
输入格式
r c; then r lines of the matrix; then q; then q lines of commands. A command is swapRows r1 r2, swapColumns c1 c2, reverseRow r, reverseColumn c, or rotate90Clockwise. The matrix must be square when it is rotated. Site supplement: r,c≤50, q≤500.
输出格式
Output the final matrix, one row per line, with values separated by spaces.
样例 1
输入:
2 3
1 2 3
4 5 6
3
swapRows 0 1
reverseColumn 1
swapColumns 0 2
输出:
6 2 4
3 5 1
样例 2
输入:
2 2
1 2
3 4
1
rotate90Clockwise
输出:
3 1
4 2
样例 3
输入:
3 2
1 2
3 4
5 6
2
reverseRow 1
reverseColumn 0
输出:
5 2
4 3
1 6