Gift for Almas
Practice
4.1 (15 votes)
Arrays
Data structures
Multi Dimensional
Problem
88% Success 2850 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

On his birthday, Almas was given a $$ n \times n $$($$1 \le n \le 500$$) matrix of natural numbers up to $$ 500 $$ and instructions for it. The instruction consisted of symbols $$ L $$ and $$ R $$, where if the symbol $$ L $$ is given you need to rotate the matrix $$ 90 $$ degrees to the left, and for the symbol $$ R $$ you need to rotate the matrix $$ 90 $$ degrees to the right. The instruction was only $$ 3 $$ characters in length so Almas could handle the twists with ease. Your task is to display the matrix that Almas had at the end of these turns.

Input

The first line consists of one integer $$ n $$ - the size of the matrix.

In the next $$ n $$ lines, you are given $$ n $$ integers. Numbers can range from $$ 1 $$ to $$ 500 $$.

Output

Output the final matrix $$ n \times n $$.

Note

Important note - you should not print any whitespace or newline if it is not necessary.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
43 votes
Tags:
ArraysBrute-force searchData StructuresEasyMulti-dimensional
Points:20
30 votes
Tags:
ArraysData StructuresEasyString Manipulation
Points:20
42 votes
Tags:
ArraysData StructuresEasyMulti-dimensional