#C1701. Rotate Matrix

    ID: 44936 Type: Default 1000ms 256MiB

Rotate Matrix

Rotate Matrix

Given an \(N \times N\) matrix, rotate it 90° clockwise in-place. The rotation is defined by the formula:

\(\text{rotated}[i][j] = \text{matrix}[N-1-j][i]\)

You must perform the rotation in-place, i.e. without using an extra matrix. Test your solution for various cases including small matrices (e.g. 1x1 and 2x2) as well as larger ones.

inputFormat

The first line contains an integer \(N\) representing the size of the matrix. The next \(N\) lines each contain \(N\) space-separated integers, denoting rows of the matrix.

outputFormat

Output the rotated matrix in the same format as the input: each row printed on a separate line with its elements separated by a space.

## sample
3
1 2 3
4 5 6
7 8 9
7 4 1

8 5 2 9 6 3

</p>