Matrix

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Problem Description
There is a matrix M that 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 are 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 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
12 13 14 15
1 2 3 4
3 4 5 6
1 10
10 1

Hint

Recommand to use scanf and printf

 
Source
思路:就是标记记录那行是原数组的那行,在原数组的那行加减就好;
代码
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define ll __int64
#define mod 1000000007
#define inf 999999999
//#pragma comment(linker, "/STACK:102400000,102400000")
ll a[][];
ll hang[],lie[],hangadd[],lieadd[];//不管你怎么换 ,都不可能把这行给拆了
int main()
{
ll casee,i,t;
scanf("%I64d",&casee);
while(casee--)
{
ll n,m,q;
memset(hangadd,,sizeof(hangadd));
memset(lieadd,,sizeof(lieadd));
scanf("%I64d%I64d%I64d",&n,&m,&q);
for(i=;i<=n;i++)
for(t=;t<=m;t++)
{
scanf("%I64d",&a[i][t]);
hang[i]=i;
lie[t]=t;
}
while(q--)
{
ll op,han,li;
scanf("%I64d%I64d%I64d",&op,&han,&li);
if(op==)
{
swap(hang[han],hang[li]);
}
else if(op==)
{
swap(lie[han],lie[li]);
}
else if(op==)
hangadd[hang[han]]+=li;
else
lieadd[lie[han]]+=li;
}
for(i=;i<=n;i++)
for(t=;t<=m;t++)
printf("%I64d%c",a[hang[i]][lie[t]]+hangadd[hang[i]]+lieadd[lie[t]],t==m?'\n':' ');
}
return ;
}

hdu 5671 Matrix 标记。。。有点晕的更多相关文章

  1. HDU 5671 Matrix 水题

    Matrix 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5671 Description There is a matrix M that has ...

  2. HDU 5671 Matrix

    Matrix Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  3. HDU 4920 Matrix multiplication(bitset)

    HDU 4920 Matrix multiplication 题目链接 题意:给定两个矩阵,求这两个矩阵相乘mod 3 思路:没什么好的想法,就把0的位置不考虑.结果就过了.然后看了官方题解,上面是用 ...

  4. HDU 2686 Matrix 3376 Matrix Again(费用流)

    HDU 2686 Matrix 题目链接 3376 Matrix Again 题目链接 题意:这两题是一样的,仅仅是数据范围不一样,都是一个矩阵,从左上角走到右下角在从右下角走到左上角能得到最大价值 ...

  5. hdu 4920 Matrix multiplication bitset优化常数

    Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

  6. hdu 2686 Matrix 最小费用最大流

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 Yifenfei very like play a number game in the n*n ...

  7. hdu 5569 matrix dp

    matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5569 D ...

  8. hdu 2119 Matrix(二分匹配)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2119 Matrix Time Limit: 5000/1000 MS (Java/Others)    ...

  9. HDU - 233 Matrix

    原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5015 解题思路:一看到题目,感觉是杨辉三角形,然后用组合数学做,不过没想出来怎么做,后来看数据+递推思 ...

随机推荐

  1. resume 简历

    1:uestc社会实践平台,sql,mapper.xml,,图片验证码,读写excel,excel和list,数据库的转化. 2:购物网站,全代码,平台搭建,服务发布,远程数据库连接,前端,搜索,支付 ...

  2. MUTABLE和IMMUTABLE集合

    Scala 集合类系统地区分了可变的和不可变的集合.可变集合可以在适当的地方被更新或扩展.这意味着你可以修改,添加,移除一个集合的元素.而不可变集合类,相比之下,永远不会改变.不过,你仍然可以模拟添加 ...

  3. selenium python 启动Chrome

    启动Chrom浏览器 下载chromedriver: http://chromedriver.storage.googleapis.com/index.html 当时找chromedriver与chr ...

  4. [LeetCode] 690. Employee Importance_Easy tag: BFS

    You are given a data structure of employee information, which includes the employee's unique id, his ...

  5. TFS修改映射路径办法

    如果你之前配置好了TFS项目的映射路径.然后每次下载项目都会在你配置的路径,但我们可以修改 方法一:我们可以在 "工作区" 中修改路径

  6. 015-awk

    1.awk的处理方式: 一次处理一行. 对每行可以进行切片处理,针对字段处理.2.awk的格式: awk BEGIN{循环之前初始化} [options] 'command' END{循环之后结尾} ...

  7. 《ABCNN: Attention-Based Convolutional Neural Network for Modeling Sentence Pairs》

    代码: keras:https://github.com/phdowling/abcnn-keras tf:https://github.com/galsang/ABCNN 本文是Wenpeng Yi ...

  8. Amaze UI JS 气泡弹出

    http://amazeui.org/javascript/popover?_ver=2.x

  9. 2016-2017-2 《Java程序设计》第5周学习总结

    学号 2016-2017-2 <Java程序设计>第5周学习总结 教材部分学习内容总结 第八章: 一.语法与继承架构 使用try.catch: •执行流程 1.尝试执行try区块中程序代码 ...

  10. 调用spark API,监控任务的进度

    我们现在需要监控datapre0这个任务每一次执行的进度,操作如下: 1. 如图所示,打开spark管理页面,找到对应的任务,点击任务名datapre0 2. 进去之后,获得对应IP和端口  3. 访 ...