#C14124. Matrix Transformation: Generate, Transpose, and Rotate

    ID: 43739 Type: Default 1000ms 256MiB

Matrix Transformation: Generate, Transpose, and Rotate

Matrix Transformation: Generate, Transpose, and Rotate

You are given two positive integers N and M. Your task is to perform a series of matrix manipulations as described below:

  • Generate the original matrix: Create a matrix of size N × M where each element at row i and column j (0-indexed) is computed by the formula: $$a_{ij} = 3i - 2j$$.
  • Transpose the matrix: Swap the rows and columns of the original matrix.
  • Rotate the transposed matrix 90 degrees clockwise: First, compute the transpose of the transposed matrix, then reverse each row of the result.

You need to output the three matrices: the original matrix, its transpose, and the rotated matrix, in the specified format.

inputFormat

The input contains a single line with two space-separated positive integers N and M (where N, M > 0), representing the number of rows and columns of the matrix respectively.

outputFormat

Output three sections:

  1. The first section begins with the line Original Matrix: followed by N lines where each line contains M space-separated integers representing a row of the original matrix.
  2. The second section begins with the line Transposed Matrix: followed by the transposed matrix rows (each row on a new line with space-separated integers).
  3. The third section begins with the line Rotated Matrix: followed by the rotated matrix rows.

See the sample test cases for clarification.

## sample
3 3
Original Matrix:

0 -2 -4 3 1 -1 6 4 2 Transposed Matrix: 0 3 6 -2 1 4 -4 -1 2 Rotated Matrix: -4 -2 0 -1 1 3 2 4 6

</p>