303311: CF641B. Little Artem and Matrix

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Little Artem and Matrix

题意翻译

## 题目描述 有一个 $n \times m$ 的矩阵,Artem 对它进行了 $q$ 次操作,每次操作一定属于下列三种中的一种: - $1 \ r$,代表对于第 $r$ 行,第一个数挪到最后一个,第二个数挪到第一个,第三个数挪到第二个,以此类推,直到最后一个数挪到倒数第二个。 - $2 \ c$,代表对于第 $c$ 列,第一个数挪到最后一个,第二个数挪到第一个,第三个数挪到第二个,以此类推,直到最后一个数挪到倒数第二个。 - $3 \ r \ c \ x$,代表查询此时第 $r$ 行第 $c$ 列的数的值,结果为 $x$。 现在 Artem 记得这 $q$ 次操作,但不记得原来的矩阵是什么样子,请你帮他还原出这个矩阵,只要与操作不矛盾即可。 ## 输入格式 第一行,三个整数,分别代表 $n$,$m$,$q$。 接下来 $q$ 行,每行输入上述的一个操作。 ## 输出格式 输出原来的矩阵。如果有多组解,输出任意一组即可。 感谢 @[oddy](https://www.luogu.com.cn/user/470348) 提供的翻译。

题目描述

Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it. That element can store information about the matrix of integers size $ n×m $ . There are $ n+m $ inputs in that element, i.e. each row and each column can get the signal. When signal comes to the input corresponding to some row, this row cyclically shifts to the left, that is the first element of the row becomes last element, second element becomes first and so on. When signal comes to the input corresponding to some column, that column shifts cyclically to the top, that is first element of the column becomes last element, second element becomes first and so on. Rows are numbered with integers from $ 1 $ to $ n $ from top to bottom, while columns are numbered with integers from $ 1 $ to $ m $ from left to right. Artem wants to carefully study this element before using it. For that purpose he is going to set up an experiment consisting of $ q $ turns. On each turn he either sends the signal to some input or checks what number is stored at some position of the matrix. Artem has completed his experiment and has written down the results, but he has lost the chip! Help Artem find any initial matrix that will match the experiment results. It is guaranteed that experiment data is consistent, which means at least one valid matrix exists.

输入输出格式

输入格式


The first line of the input contains three integers $ n $ , $ m $ and $ q $ ( $ 1<=n,m<=100,1<=q<=10000 $ ) — dimensions of the matrix and the number of turns in the experiment, respectively. Next $ q $ lines contain turns descriptions, one per line. Each description starts with an integer $ t_{i} $ ( $ 1<=t_{i}<=3 $ ) that defines the type of the operation. For the operation of first and second type integer $ r_{i} $ ( $ 1<=r_{i}<=n $ ) or $ c_{i} $ ( $ 1<=c_{i}<=m $ ) follows, while for the operations of the third type three integers $ r_{i} $ , $ c_{i} $ and $ x_{i} $ ( $ 1<=r_{i}<=n $ , $ 1<=c_{i}<=m $ , $ -10^{9}<=x_{i}<=10^{9} $ ) are given. Operation of the first type ( $ t_{i}=1 $ ) means that signal comes to the input corresponding to row $ r_{i} $ , that is it will shift cyclically. Operation of the second type ( $ t_{i}=2 $ ) means that column $ c_{i} $ will shift cyclically. Finally, operation of the third type means that at this moment of time cell located in the row $ r_{i} $ and column $ c_{i} $ stores value $ x_{i} $ .

输出格式


Print the description of any valid initial matrix as $ n $ lines containing $ m $ integers each. All output integers should not exceed $ 10^{9} $ by their absolute value. If there are multiple valid solutions, output any of them.

输入输出样例

输入样例 #1

2 2 6
2 1
2 2
3 1 1 1
3 2 2 2
3 1 2 8
3 2 1 8

输出样例 #1

8 2 
1 8 

输入样例 #2

3 3 2
1 2
3 2 2 5

输出样例 #2

0 0 0 
0 0 5 
0 0 0 

Input

题意翻译

## 题目描述 有一个 $n \times m$ 的矩阵,Artem 对它进行了 $q$ 次操作,每次操作一定属于下列三种中的一种: - $1 \ r$,代表对于第 $r$ 行,第一个数挪到最后一个,第二个数挪到第一个,第三个数挪到第二个,以此类推,直到最后一个数挪到倒数第二个。 - $2 \ c$,代表对于第 $c$ 列,第一个数挪到最后一个,第二个数挪到第一个,第三个数挪到第二个,以此类推,直到最后一个数挪到倒数第二个。 - $3 \ r \ c \ x$,代表查询此时第 $r$ 行第 $c$ 列的数的值,结果为 $x$。 现在 Artem 记得这 $q$ 次操作,但不记得原来的矩阵是什么样子,请你帮他还原出这个矩阵,只要与操作不矛盾即可。 ## 输入格式 第一行,三个整数,分别代表 $n$,$m$,$q$。 接下来 $q$ 行,每行输入上述的一个操作。 ## 输出格式 输出原来的矩阵。如果有多组解,输出任意一组即可。 感谢 @[oddy](https://www.luogu.com.cn/user/470348) 提供的翻译。

加入题单

算法标签: