Matrix Multiplication

2020年1月17日 1139点热度 0人点赞 0条评论

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

提示:

参考答案:

解锁文章

没有看到答案?微信扫描二维码可免费解锁文章

微信扫描二维码解锁

使用微信扫描二维码打开广告页面后可以立即关闭,再刷新此页面即可正常浏览此文章

所跳转广告均由第三方提供,并不代表本站观点!

已经扫描此二维码?点此立即跳转

code

这个人很懒,什么都没留下

文章评论