#K69097. Matrix Rotation and Stringification

    ID: 33010 Type: Default 1000ms 256MiB

Matrix Rotation and Stringification

Matrix Rotation and Stringification

You are given a square matrix of size (N \times N) along with an operation code. Depending on the operation code, you need to perform one of two tasks:

  • If the operation code is 1, rotate the matrix by \(90^\circ\) clockwise and print the resulting matrix.
  • If the operation code is 2, output the original matrix in its string representation.

The matrix is provided as (N) lines of space-separated integers. Your output should print the matrix in the same format: each row on a new line with a single space separating the numbers. Use LaTeX formatting where necessary.

inputFormat

The input is read from standard input and is formatted as follows:

  • The first line contains an integer representing the operation code (1 or 2).
  • The second line contains an integer \(N\), the size of the square matrix.
  • The next \(N\) lines each contain \(N\) space-separated integers representing the rows of the matrix.

outputFormat

Output the result to standard output based on the operation code:

  • If the operation code is 1, output the rotated matrix in which each row is printed on a new line with space-separated integers.
  • If the operation code is 2, output the original matrix as a string in the same format.
## sample
1
2
1 2
3 4
3 1

4 2

</p>