Submit  All submissions  Best solutions  Back to list 
SHIFT  Shift 
You are given matrix z (n x m) and two integers x and y.
The value of x represents the displacement of matrix z in the horizontal direction (positive value is offset to the right, negative to left), and the value of y represents the shift of matrix z in the vertical direction (positive value upward, negative downward).
Input
Input consist of unknown number of test cases.
Each of them contain integers n and m (n,m<111). Then, in each of n lines are m numbers. Finally, at the end of each test appear x and y (1000<x,y<1000).
Input ends when n=m=0.
Output
Matrix after shift (as in the example  with blank line at the end of each test).
Example
Input:
3 3
1 2 3
4 5 6
7 8 9
2 1
3 4
6 7 8 5
10 11 12 9
2 3 4 1
3 2
0 0
Output:
8 9 7
2 3 1
5 6 4
1 2 3 4
5 6 7 8
9 10 11 12
Added by:  Piotr Kąkol 
Date:  20100704 
Time limit:  14.92s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS OBJC SCM qobi VB.NET 
Resource:  Brazilian Olympiad in Informatics 
hide comments
20140604 15:16:41 Dominique VAILLANT
@Mitch: Another fabulous score! You are promoting Ruby as a star language on SPOJ SHORTEN. Furthermore it's not an easy job to beat Jander/Perl! 

20100714 15:34:26 Piotr KÄ…kol
I knew I forgot about something. ;) One more time sorry for my mistake. 

20100714 12:40:55 HWK
Is there something wrong with the data? Pythonsolutions from three persons give NZEC. At home my code runs without problems? I suppose the code from the others does it too. Edit: The last line seems to be the problem. Is it really "0 0"? Last edit: 20100714 14:51:09 

20100713 18:53:11 Piotr KÄ…kol
If the explanation of the task isn't clear enought write here Your questions. 