Hdoj Matrix 5671 (matrices Simulation & Tricks)

Source: Internet
Author: User
Matrix Time limit:3000/1500 MS (java/others) Memory limit:131072/131072 K (java/others)
Total submission (s): 1021 Accepted Submission (s): 425


Problem Description There is a matrix M which has n rows and M columns (1≤n≤1000,1≤m≤1000). Then we perform q (1≤q≤100,000) operations:

1 x y:swap row x and Row y (1≤x,y≤n);

2 x y:swap column x and column y (1≤x,y≤m);

3 x y:add y to all elements in row x (1≤x≤n,1≤y≤10,000);

4 x y:add y to all elements in column x (1≤x≤m,1≤y≤10,000);
Input There is multiple test cases. The first line of input contains an integer T (1≤t≤20) indicating the number of test cases. For each test case:

The first line contains three integers n, m and Q.
The following n lines describe the matrix M. (1≤mi,j≤10,000) for All (1≤i≤n,1≤j≤m).
The following q lines contains three integers a (1≤a≤4), X and Y.

Output for each test case, output of the matrix M after all Q operations.
Sample Input
2 3 4 2 1 2 3 4 2 3 4 5 3 4 5 6 1 1 2 3 1 10 2 2 2 1 10 10 1 1 1 2 2 1 2
Sample Output
1 2 3 4 3 4 5 6 1 ten 1 Hint recommand to use scanf and printf problem description
There is an nn row mm column matrix (1 \leq n \leq, 1 \leq m \leq 1000) (1≤n≤1000,1≤m≤1000), on this matrix QQ  (1 \leq q \leq 100,000) (1≤q≤100,00 0) Operation:

1 x y: The first xx line of the switch matrix mm and the yy line (1 \leq x, y \leq N) (1≤x,y≤n);
2 x y: Column xx and section of the switch matrix mm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.