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. POJ3096:Surprising Strings(map)

    http://poj.org/problem?id=3096 for循环真是奇妙! #include <string.h> #include <stdio.h> #includ ...

  2. hduPiggy-Bank(完全背包)

    http://acm.hdu.edu.cn/showproblem.php?pid=1114 此题就是最简单的完全背包,顺序!!! for i=1..N for v=0..V f[v]=max{f[v ...

  3. jquery更改表格行顺序实例

    使用jquery写的更改表格行顺序的小功能 表格部分: 复制代码代码如下: <table class="table" id="test_table"> ...

  4. matlab 以excel格式将字符串数组写入TXT文件

    [m, n] = size(FFoutpu);fp = fopen('FFoutpu.txt','wt');fprintf(fp, 'name CODE ROTC EBIT_EV SHIZHI ROT ...

  5. ajax提交form(文本数据以及文件上传)

    $.ajax({ url: 'xxxx.do', type: 'POST', cache: false, data: new FormData($('.layui-form')[0]), proces ...

  6. BP神经网络的Java实现(转)

    http://fantasticinblur.iteye.com/blog/1465497 课程作业要求实现一个BPNN.这次尝试使用Java实现了一个.现共享之.版权属于大家.关于BPNN的原理,就 ...

  7. Visual Studio 2013旗舰版KEY

    Visual Studio 2013旗舰版KEY:BWG7X-J98B3-W34RT-33B3R-JVYW9

  8. java模拟表单上传文件,java通过模拟post方式提交表单实现图片上传功能实例

    java模拟表单上传文件,java通过模拟post方式提交表单实现图片上传功能实例HttpClient 测试类,提供get post方法实例 package com.zdz.httpclient; i ...

  9. JProfiler8 远程监控tomcat配置过程

    1. 阅读人群 1.熟悉liunx服务器,起码知道liunx常见的命令 2.熟悉tomcat容器,起码知道怎么tomcat的启动以及停止 3.熟悉java编程语言,JProfiler8是专门监控jav ...

  10. C语言实现strlen函数的几种方法

    原文地址:http://www.51testing.com/html/72/n-221172.html 传说常见的一个笔试题:不使用中间变量求const字符串长度,即实现求字符串长度库函数strlen ...