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及方法签名都存储在定义范围中.实际例程创建于实施范围中.使用 ...
随机推荐
- Nginx配置参数中文说明
#定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_processes 8; #全局错误日志定义类型,[ debu ...
- markdown的流程图、时序图、甘特图画法
https://www.jianshu.com/p/a9ff5a9cdb25 Markdown里面的序列图 https://shd101wyy.github.io/markdown-preview-e ...
- Ubuntu配置Nginx虚拟主机和支持ThinkPHP
[Nginx配置虚拟主机] 每一个 server { listen 80; server_name www.a.com; ..... } 就表示一台虚拟域名, 然后对应的 ...
- 原生Java代码拷贝目录
拷贝.移动文件(夹),有三方包commons-io可以用,但是有时候有自己的需求,只能使用原生java代码,这时可以用以下几种方式进行拷贝: 1.使用系统命令(Linux)调用 此种方式对操作系统有要 ...
- Java经典编程题50道之十六
输出九九乘法表. public class Example16 { public static void main(String[] args) { table(9); } ...
- C语言链表的建立、插入和删除
先看下向链表中插入节点 下面这个是删除链表节点
- CentOS下安装配置cmake
安装环境:CentOS-6.4 安装方式:源码编译安装 软件:cmake-2.8.5.tar.gz 下载地址暂时不提供,去百度搜一下准有 安装前提 系统中已经安装了gcc. ncurses-de ...
- 电脑太卡怎么解决-IT33
首先我们看一下引起电脑卡顿的原因有哪些: 1. 电脑可能感染木马病毒. 2. 硬盘使用时间过长,硬盘有坏道. 3. 软件开太多导致内存不足. 4. 电脑磁盘中冗余或者碎片过多. 5. ...
- java 集合框架(一)概述
一.概述 Java Collection Framework (JCF) 提供给我们一系列的类和接口,方便开发者处理集合对象. 在Java 2之前,Java是没有完整的集合框架的.它只有一些简单的可以 ...
- 八爪鱼采集器︱加载更多、再显示20条图文教程(Xpatth、Ajax)
每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- 由于代码布置采集器比较麻烦,又很早知道八爪鱼采 ...