Matrix Multiplication
时间: 1ms 内存:64M
描述:
You are given a matrix M of type 1234x5678. It is initially filled with integers 1...1234x5678 in row major order. Your task is to process a list of commands manipulating M. There are 4 types of commands:
"R x y" swap the xth and yth row of M; 1<=x, y<=1234.
"C x y" swap the xth and yth column of M; 1<=x, y<=5678.
"Q x y" write out M(x, y); 1<=x<=1234.1<=y<=5678.
"W z" write out x and y where z=M(x, y). 1<=z<=7006652 (1234 * 5678)
输入:
The input file contains several test cases. The first line is N: the number of test cases. Then follows N lines. A list of valid commands.1 <= N <= 10000.
输出:
For each "Q x y" write out one line with the current value of M(x, y), for each "W z" write out one line with the value of x and y (described as above) separated by a space.
示例输入:
10
R 1 2
Q 1 1
Q 2 1
W 1
W 5679
C 1 2
Q 1 1
Q 2 1
W 1
W 5679
示例输出:
5679
1
2 1
1 1
5680
2
2 2
1 2
提示:
参考答案:
解锁文章
文章评论