UberOA #46
Matrix Transformation
估计简单可在线判题
考点(AI 标注)模拟/实现原地数组
Apply the given transformations to a square matrix in order. This site defines the operation codes explicitly: 0 rotates 90 degrees clockwise, 1 reflects across the main diagonal, and 2 reflects across the anti-diagonal.
This site has made the standard input and output explicit.
输入格式
The first line contains n q, followed by n lines of n integers each, and a last line with q operation codes. On this site 1≤n≤500, 0≤q≤200000, and elements are in −10⁹..10⁹.
输出格式
Output the transformed matrix, n integers per line.
样例 1
输入:
3 3
1 2 3
4 5 6
7 8 9
0 1 2
输出:
3 6 9
2 5 8
1 4 7
样例 2
输入:
2 1
1 2
3 4
1
输出:
1 3
2 4
样例 3
输入:
1 0
9
输出:
9
样例说明
Example 1: after transforming in order, the rows are 3 6 9, 2 5 8, 1 4 7. Example 2: transposing across the main diagonal gives 1 3, 2 4. Example 3: with no operations, it is still 9.