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. 容器集成平台 rancher部署

    下载rancher镜像 docker pull rancher/server:stable rancher/server:latest #开发版 rancher/server:stable #稳定版 ...

  2. Codeforces 1144G Two Merged Sequences

    题意: 将一个序列分成两个序列,两个序列中元素的相对顺序保持和原序列不变,使得分出的两个序列一个严格上升,一个严格下降. 思路: 我们考虑每个元素都要进入其中一个序列. 那么我们维护一个上升序列和一个 ...

  3. python , 顺序迭代合并后的list对象

    有一系列排序序列,想将它们合并后得到一个排序序列并在上面迭代遍历 heapq.merge() 函数可以帮你解决这个问题.比如: >>> import heapq >>&g ...

  4. Linux命令: 向文件写内容,编辑文件,保存文件,查看文件,不保存文件

    1.找到要编辑的文件 2.敲  vi t1.txt ,显示文件内容(vim命令) 3.敲 i,最下面变成INSERT 4.编辑自己想要的内容 5a.敲ESC:wq回车 5b.如果不想保存文件在时敲ES ...

  5. 2018-2019-2 20165209 《网络对抗技术》Exp5:MSF基础应用

    2018-2019-2 20165209 <网络对抗技术>Exp5:MSF基础应用 目录 一.基础问题回答和实验内容 二.攻击实例 主动攻击的实践 ms08_067 payload/gen ...

  6. nodepad++ 标签栏无法拖放标签

    nodepad++ 标签栏无法拖放标签设置--首选项--常用--标签栏--锁定(不允许拖放) 去掉这个勾 ps:最近版本的不知道为什么这个设置不生效了,没找到原因,可能是bug,只能等待升级解决了(升 ...

  7. Ubuntu系统下查看显卡相关信息

    查看显卡信息 root@ubuntu:/home/ubuntu# lspci |grep -i vga 02:00.0 VGA compatible controller: NVIDIA Corpor ...

  8. POI Excel文件的读取与写入

    1. 创建目录 if(!(new File(path).isDirectory())){ new File(path).mkdirs();} 2. 读取Excel文件,并进行写入操作 Workbook ...

  9. 20145101《Java程序设计》第10周学习总结

    20145101<Java程序设计>第10周学习总结 教材学习内容总结 网络编程 网络编程的实质就是两个(或多个)设备(例如计算机)之间的数据传输. 计算机网络 路由器和交换机组成了核心的 ...

  10. Java第一次实验 20145104张家明

    Java第一次实验 实验报告 实验要求: 1.使用JDK编译.运行简单的Java程序 2.使用IDEA 编辑.编译.运行.调试Java程序 实验内容: 1.使用JDK编译.运行简单的Java程序: 2 ...