You are given a square matrix of dimension N. Let this matrix be called A. Your task is to rotate A in clockwise direction byS degrees, where S is angle of rotation. On the matrix, there will be 3 types of operations viz.
- Rotation
Rotate the matrix A by angle S, presented as input in form of A S - Querying
Query the element at row K and column L, presented as input in form of Q K L - Updation
Update the element at row X and column Y with value Z, presented as input in form of U X Y Z
Print the output of individual operations as depicted in Output Specification
Input Format:
Input will consist of three parts, viz.
1. Size of the matrix (N)
2. The matrix itself (A = N * N)
3. Various operations on the matrix, one operation on each line. (Beginning either with A, Q or U)
-1 will represent end of input.
Input will consist of three parts, viz.
1. Size of the matrix (N)
2. The matrix itself (A = N * N)
3. Various operations on the matrix, one operation on each line. (Beginning either with A, Q or U)
-1 will represent end of input.
Note:
- Angle of rotation will always be multiples of 90 degrees only.
- All Update operations happen only on the initial matrix. After update all the previous rotations have to be applied on the updated matrix
Output Format:
For each Query operation print the element present at K-L location of the matrix in its current state.
For each Query operation print the element present at K-L location of the matrix in its current state.
Constraints:
Sample Input and Output
| SNo. | Input | Output |
|---|---|---|
| 1 | 2 1 2 3 4 A 90 Q 1 1 Q 1 2 A 90 Q 1 1 U 1 1 6 Q 2 2 -1 | 3 1 4 6 |
Note:
Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:
Participants submitting solutions in C language should not use functions from/ as these files do not exist in gcc
Participants submitting solutions in C language should not use functions from


0 Comments