SOLVE

LATER

Rubik's Square

Problem

Editorial

Analytics

Raj has bought a new Rubik's Cube and he try to solve it day and night. Seeing this , Vikas tried to help Raj by giving him problem based on cube Rotation . To make it easier for Raj , As Raj is a beginner Vikas gave problem in square matrix instead of cube. The problem is as follows :

Vikas has **N*N** array of different numbers. Now he rotates the rows and columns . Raj has to stay focused and tell Vikas what should be output of matrix after **R** Rows Rotation and **C** columns rotation.

Raj is now more confused then ever from the above problem. Help him to find the answer.

**Note:** First all the rows will be rotated and then all the columns will be rotated. Rotation will be from left to right (for Rows) and Top to Bottom (for Column).

**Input :**

First line contain the N,R,C;

Next N lines contains N space separated integer denoting element in matrix.

Next line contains R space separated integer denoting index of Row to be rotated.(Index starts from 1).

Next line contains C space separated integer denoting index of Column to be rotated.(Index starts from 1).

**Output:**

Output the N*N matrix generated after above operation.

**Constraints:**
1<=N<=1000

1<=R,C<=100000

**Example :**

**Test case 1:**

**Input :**

3 1 0

1 2 3

4 5 6

7 8 9

2

**Output:**

1 2 3

6 4 5

7 8 9

**Test case 2:**

**Input :**

4 2 2

1 2 3 4

5 6 7 8

9 1 1 3

4 5 7 8

2 2

1 3

**Output :**

4 2 7 4

1 8 3 6

7 1 5 3

9 5 1 8

Time Limit:
1.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
C,
C++,
C++14,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Julia,
Kotlin,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Swift-4.1,
Visual Basic

Initializing Code Editor...

{"f618d55": "/pagelets/show-submission/algorithm/rubiks-square-2/", "7f2d96c": "/pagelets/suggested-problems/algorithm/rubiks-square-2/", "05152fb": "/pagelets/problems-hint/algorithm/rubiks-square-2/", "4c7f8f0": "/pagelets/recommended-problems/algorithm/rubiks-square-2/", "35fab9d": "/pagelets/problem-author-tester/algorithm/rubiks-square-2/"}

realtime.hackerearth.com

80

08efb758b62110ec5ff8d779640accc25b95623f

58a29e5cae2309f04b28

/realtime/pusher/auth/