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及方法签名都存储在定义范围中.实际例程创建于实施范围中.使用 ...
随机推荐
- NOIP2016提高组初赛(C++语言)试题 个人的胡乱分析 Part 3.
*已更新 胡乱分析的第三部分,程序填空(所谓的完善程序) 说到初赛,好像本周六就是了.哇好激动.. 填空题都是玄学.也许get到点了就会好做一些.. (标红的是填在空里的答案) T1.交朋友 (小矮个 ...
- BZOJ 1815: [Shoi2006]color 有色图 [Polya DFS 重复合并]
传送门 题意: 染色图是无向完全图,且每条边可被染成k种颜色中的一种.两个染色图是同构的,当且仅当可以改变一个图的顶点的编号,使得两个染色图完全相同.问N个顶点,k种颜色,本质不同的染色图个数(模质数 ...
- C 洛谷 P3599 Koishi Loves Construction [构造 打表观察]
题目描述 Koishi决定走出幻想乡成为数学大师! Flandre听说她数学学的很好,就给Koishi出了这样一道构造题: Task1:试判断能否构造并构造一个长度为的的排列,满足其个前缀和在模的意义 ...
- Linux修改IP永久生效
修改IP永久生效按以下方法: 1)修改配置文件vi /etc/sysconfig/network-scripts/ifcfg-eth0(eth0,第一块网卡,如果是第二块则为eth1) 按如下修改ip ...
- 【IT人】如何提高阅读源代码的效率
1.最近刚到公司,公司就发一架构代码自己看,看了几天看的想吐,也在网上找了下相关的技巧吧,不是有句话叫做:成功必有方法,失败总是借口! 2.借鉴别人的方法来看看如下: 记得在开源流行之前,我看过的代码 ...
- LeetCode - 657. Judge Route Circle
Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot m ...
- 企业Nginx+Keepalived双主架构案例实战
通过上一次课程的学习,我们知道Nginx+keepalived主从配置,始终有一台服务器处于空余状态,那如何更好的利用起来呢,我们需要借助Nginx+keepalived双主架构来实现,如下图通过改装 ...
- Mysql(二):库操作
一 系统数据库 information_schema: 虚拟库,不占用磁盘空间,存储的是数据库启动后的一些参数,如用户表信息.列信息.权限信息.字符信息等performance_schema: MyS ...
- iOS——系统提供的dispatch方法
// 后台执行: dispatch_async(dispatch_get_global_queue(0,0), ^{ // something }); // 主线程执行: dispatch_async ...
- css的一些复习
css,全称Cascading Style Sheets,层叠样式表. css选择器是从右往左解析的,解析速度会比较快. 选择器 选择器权重 !important 优先级最高 元素属性 优先级高 相同 ...