HDU 5671 Matrix
Matrix
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 502 Accepted Submission(s):
215
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) ;
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≤M,i,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 .
Recommand to use scanf and printf
#include <iostream>
#include <string.h>
using namespace std;
int h[],l[], zh[], zl[];
int a[][];
int main()
{
int T, n, m, q, i, j, c, x, y, t;
cin>>T;
while(T--)
{
memset(zh,,sizeof(zh));
memset(zl,,sizeof(zl));
for(i=;i<=;i++)
h[i]=l[i]=i;
scanf("%d%d%d", &n, &m, &q);
for(i=;i<=n;i++)
for(j=;j<=m;j++)
scanf("%d", &a[i][j]);
while(q--)
{
scanf("%d%d%d", &c, &x, &y);
if(c==) {t=h[x];h[x]=h[y];h[y]=t;}
else if(c==) {t=l[x];l[x]=l[y];l[y]=t;}
else if(c==) zh[h[x]] += y;
else if(c==) zl[l[x]] += y;
}
for(i=;i<=n;i++)
{
for(j=;j<=m;j++)
if(j==)
printf("%d", a[h[i]][l[j]]+zh[h[i]]+zl[l[j]]);
else
printf(" %d", a[h[i]][l[j]]+zh[h[i]]+zl[l[j]]);
printf("\n");
}
}
return ;
}
HDU 5671 Matrix的更多相关文章
- HDU 5671 Matrix 水题
Matrix 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5671 Description There is a matrix M that has ...
- hdu 5671 Matrix 标记。。。有点晕
Matrix Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Problem ...
- HDU 4920 Matrix multiplication(bitset)
HDU 4920 Matrix multiplication 题目链接 题意:给定两个矩阵,求这两个矩阵相乘mod 3 思路:没什么好的想法,就把0的位置不考虑.结果就过了.然后看了官方题解,上面是用 ...
- HDU 2686 Matrix 3376 Matrix Again(费用流)
HDU 2686 Matrix 题目链接 3376 Matrix Again 题目链接 题意:这两题是一样的,仅仅是数据范围不一样,都是一个矩阵,从左上角走到右下角在从右下角走到左上角能得到最大价值 ...
- hdu 2686 Matrix 最小费用最大流
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 Yifenfei very like play a number game in the n*n ...
- hdu 5569 matrix dp
matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5569 D ...
- hdu 2119 Matrix(二分匹配)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2119 Matrix Time Limit: 5000/1000 MS (Java/Others) ...
- HDU - 233 Matrix
原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5015 解题思路:一看到题目,感觉是杨辉三角形,然后用组合数学做,不过没想出来怎么做,后来看数据+递推思 ...
- HDU——2119 Matrix
Matrix Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
随机推荐
- paper 52 :windows7环境下theano安装
要做卷积神经网络的一些东西,所以要装theano,网上很多Theano安装教程版本较老,而各安装包更新很快,参考价值有限.走了很多弯路才装好,把这个过程记录下来,希望对大家有帮助~ ~ 我的配置:wi ...
- Open quote is expected for attribute "property" associated with an element type "result".错误
java Mybatis 框架下的项目 报 Open quote is expected for attribute "property" associated with a ...
- logstash5.x改变
5.x版本 logstash中 elasticsearch插件的workers,无法配置大于1,会提示 This plugin uses the shared and doesn't need thi ...
- 响应式框架pure--来自雅虎
梦想还是要有 http://www.purecss.org/
- PAT乙级 1018. 锤子剪刀布 (20)
1018. 锤子剪刀布 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 大家应该都会玩“锤子剪刀布”的游 ...
- bodybuilding
增大肌肉块的14大秘诀:大重量.低次数.多组数.长位移.慢速度.高密度.念动一致.顶峰收缩.持续紧张.组间放松.多练大肌群.训练后进食蛋白质.休息48小时.宁轻勿假. 1. 大重量.低次数:健美理论中 ...
- jstl和jsp脚本变量相互访问
1.jsp脚本访问jstl标准动作的变量,可以通过隐式的范围变量来获取,对于页面作用域的变量,可以通过pageContext.getAttribute()来获取,也可以通过动作来获取: <c:s ...
- mysql之使用xtrabackup进行物理备份、恢复、在线克隆从库、在线重做主从
注:图片来自<深入浅出MySQL 数据库开发 优化与管理维护 第2版> 物理备份和恢复 1.冷备份:停掉mysql再备份,一般很少用,因为很多应用不允许长时间停机,停机备份的可以直接CP数 ...
- java面试每日一题11
题目:求1+2!+3!+...+20!的和 public class Recursion { public static void main(String args[]) throws NumberF ...
- HDU 4707:Pet
Pet Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...