hdu 5671 Matrix 标记。。。有点晕
Matrix
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
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);
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.
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
1 2 3 4
3 4 5 6
1 10
10 1
Recommand to use scanf and printf
#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 标记。。。有点晕的更多相关文章
- 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)Total Su ...
- 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 4920 Matrix multiplication bitset优化常数
Matrix multiplication Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- 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 解题思路:一看到题目,感觉是杨辉三角形,然后用组合数学做,不过没想出来怎么做,后来看数据+递推思 ...
随机推荐
- 如何给Pycharm加上头行 # *_*coding:utf-8 *_*?
File>Setting>Editor>Code Style>File and Code Templates>Python Script 后面加上 # *_*codin ...
- Build-in Function:abs(),all(),any(),assii(),bin(),issubclass(),bytearray(),isinstance()
print('abs():输出绝对值,是absolute的缩写--------------') print(abs(-1)) print('all()与any()------------------- ...
- sklearn总览
- pandas取dataframe特定行/列
1. 按列取.按索引/行取.按特定行列取 import numpy as np from pandas import DataFrame import pandas as pd df=DataFram ...
- jQ live用法
我们给元素绑定单击事件.用得最多的都是$("#id").click(function(){}); 但我们动态添加的元素.这样绑定是不行的.必须借助live $("#id ...
- Object之clone
一.Object类中clone的实现. 二.clone详解. 看,clone()方法又是一个被声明为native的方法,因此,我们知道了clone()方法并不是Java的原生方法,具体的实现是有C/C ...
- requirejs初体验
1.引入requirejs <script type="text/javascript" src="/js/common/require2.3.5.js" ...
- python解决matplotlib中文坐标值乱码的问题
加上这句话即可 plt.rcParams['font.sans-serif']=['SimHei'] 效果:
- 缓存(图像 IO 14.2)
缓存 如果有很多张图片要显示,最好不要提前把所有都加载进来,而是应该当移出屏幕之后立刻销毁.通过选择性的缓存,你就可以避免来回滚动时图片重复性的加载了. 缓存其实很简单:就是存储昂贵计算后的结果(或者 ...
- 持续集成之三:搭建Maven私服Nexus
安装环境 Red Hat Enterprise Linux Server release 7.3 (Maipo) jdk1.7.0_80 apache-tomcat-7.0.90 mysql-5.7. ...