CF367 E - Working routine
十字链表模拟
#include<bits/stdc++.h>
using namespace std; int n,m,q;
struct Node{
int v; int d,r;
}ma[1005*1005];
int C(int x,int y){
return x*(m+1)+y;
} int main(){
while(~scanf("%d %d %d",&n,&m,&q)) {
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j) {
scanf("%d",&ma[C(i,j)].v);
}
for(int i = 0; i <= n; ++i)
for(int j = 0; j <= m; ++j) {
ma[C(i,j)].r = C(i,j+1);
ma[C(i,j)].d = C(i+1,j);
}
for(int i = 0; i < q; ++i) {
int a,b,c,d,h,w; scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&h,&w);
int t1 = 0; int t2 = 0;
for(int i = 1; i < a; ++i) t1 = ma[t1].d;
for(int i = 1; i < b; ++i) t1 = ma[t1].r;
for(int i = 1; i < c; ++i) t2 = ma[t2].d;
for(int i = 1; i < d; ++i) t2 = ma[t2].r;
int x1,x2; x1 = t1; x2 = t2;
for(int i = 1; i <= w; ++i) {
x1 = ma[x1].r; x2 = ma[x2].r;
swap(ma[x1].d, ma[x2].d);
}
for(int i = 1; i <= h; ++i) {
x1 = ma[x1].d; x2 = ma[x2].d;
swap(ma[x1].r, ma[x2].r);
} x1 = t1, x2 = t2;
for(int i = 1; i <= h; ++i) {
x1 = ma[x1].d; x2 = ma[x2].d;
swap(ma[x1].r, ma[x2].r);
}
for(int i = 1; i <= w; ++i) {
x1 = ma[x1].r; x2 = ma[x2].r;
swap(ma[x1].d, ma[x2].d);
}
} int tt = 0;
for(int i = 1; i <= n; ++i) {
tt = ma[tt].d;
int t1 = tt;
for(int j = 1; j <= m; ++j) {
t1 = ma[t1].r;
if(j!=1) printf(" ");
printf("%d",ma[t1].v);
} printf("\n");
} }
return 0;
}
CF367 E - Working routine的更多相关文章
- What is the difference between routine , method , procedure , function ? please explain it with example?
a method is named and attached to an object. so, for example, a method is like a function but is con ...
- End Routine
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- Routine Problem(数学)
Routine Problem time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- ABAP中Conversion Routine示例
在SAP的Domain定义中,Output Length下面有个Convers. routine的标识,这是SAP用来进行输入输出转换的.我们知道,屏幕上的I/O字段都是字符串形式的,而数 ...
- 用完成例程(Completion Routine)实现的重叠I/O模型
/// 用完成例程(Completion Routine)实现的重叠I/O模型 /// 异步IO模型 /// 用完成例程来实现重叠I/O比用事件通知简单得多.在这个模型中,主线程只用不停的接受连接 / ...
- mysql存储过程出现OUT or INOUT argument 10 for routine
OUT or INOUT argument 10 for routine * is not a variable or NEW pseudo-variable 我查网上很多出现在call的时候没有添加 ...
- mysql存储过程 OUT or INOUT argument 3 for routine
mysql存储过程出现: OUT or INOUT argument 3 for routine gotask.UserLogin is not a variable or NEW pseudo-va ...
- 十字链表 Codeforces Round #367 E Working routine
// 十字链表 Codeforces Round #367 E Working routine // 题意:给你一个矩阵,q次询问,每次交换两个子矩阵,问最后的矩阵 // 思路:暴力肯定不行.我们可以 ...
- SAP BW 例程(Routine)【开始例程、关键值或特性的例程、结束例程】
定义 可以使用例程定义关键值或特性的复杂的转换规则. 例程是本地 ABAP 类,它们包括预定义的定义和实施范围.进站和出站参数的 TYPES及方法签名都存储在定义范围中.实际例程创建于实施范围中.使用 ...
随机推荐
- HDU 3595 GG and MM [Every-SG]
传送门 题意: 两个数$x,y$,一个人的决策为让大数减去小数的任意倍数(结果不能为负),出现0的人胜 一堆这样的游戏同时玩 Every-SG 游戏规定,对于还没有结束的单一游戏,游戏者必须对该游戏进 ...
- OI黑科技:读入优化
利用getchar()函数加速读入. Q:读入优化是什么? A :更加快速地读入一些较大的数字. Q:scanf不是已经够快了吗? A:Naive,scanf还是不!够!快! Q:那怎么办呢? A:我 ...
- redis新手入门,摸不着头脑可以看看<二>
对<Redis开发与运维>的理解--下文中引号部分来自该书,略有修改 P19. Redis有序集合(图2-1) "Redis有序集合和集合一样也是某种类型元素的集合,不重复.不 ...
- JSP的几种跳转方式的异同
1 <jsp:foward page="url" /> 服务端跳转,立即跳转,后续语句不会执行: 2 <% response.sendRedirect(" ...
- Ios App上传步骤
前言:作为一名IOS开发者,把开发出来的App上传到App Store是必须的.下面就来详细介绍下具体流程. 1.打开苹果开发者中心:https://developer.apple.com 打开后点击 ...
- visual studio code右侧的预览面板能关闭吗?
https://segmentfault.com/q/1010000010082399 "editor.minimap.enabled":false
- 解决nginx [error] open() "usr/local/nginx/logs/nginx.pid" failed错误
重新启动服务器,访问web服务发现无法浏览啦!登陆服务器之 后进到nginx使用./nginx -s reload重新读取配置文件,发现报nginx: [error] open() "/us ...
- PHP系统左侧菜单栏的管理与实现
在日常的开发工作中,面对后台的日益增长的业务,以及后期业务的迭代开发,通常会选择添加菜单栏的形式来扩充业务功能,同样日益增长的后台菜单选项也为我们后期的维护,产生了一定的困难性.为此我总结出自己关于左 ...
- Android 文件下载三种基本方式
一.自己封装URLConnection 连接请求类 public void downloadFile1() { try{ //下载路径,如果路径无效了,可换成你的下载路径 String url = & ...
- 【Unity3D技术文档翻译】第1.1篇 AssetBundle 工作流
译者前言:本章是关于从创建到加载,再到使用 AssetBundle 的整个流程的概述.阅读本章将对 AssetBundle 的工作流程有个简单而全面的了解. 本章原文所在章节:[Unity Manua ...