样例输入:

4 4 2
a a b b
a a b b
c c d d
c c d d
1 1 3 3 2 2
3 1 1 3 2 2

样例输出:

d d c c 
d d c c 
b b a a 
b b a a 

思路:

既然是在矩形里面操作,而且每次移动的是一个整块,同时移动的一对矩形不会相邻

那么就使用一个四向链表模拟矩形,保存每个节点的上下左右节点

实际使用时发现其实双向(向下和向右)就够了

代码:

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<string>
using namespace std;
int n,m,q;
struct point{
string v;
int r,d;
}ma[];
int trans(int x,int y){
return y*(m+)+x;
}
int pos(int x,int y){
if (x>y){
int ans=trans(x,);
for (int i=;i<y;i++) ans=ma[ans].d;
return ans;
}
else {
int ans=trans(,y);
for (int i=;i<x;i++) ans=ma[ans].r;
return ans;
}
} int main(){
std::ios::sync_with_stdio(false);
cin>>n>>m>>q;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++){
if (i&&j) cin>>ma[trans(j,i)].v;
ma[trans(j,i)].r=trans(j+,i);
ma[trans(j,i)].d=trans(j,i+);
} while(q--){
int x1,y1,x2,y2,l,c;
cin>>y1>>x1>>y2>>x2>>l>>c;
int p1=pos(x1-,y1-),p2=pos(x2-,y2-);
int t1=p1,t2=p2;
for(int i=;i<=l;i++){
t1=ma[t1].d;t2=ma[t2].d;
swap(ma[t1].r,ma[t2].r);
}
for(int i=;i<=c;i++){
t1=ma[t1].r;t2=ma[t2].r;
swap(ma[t1].d,ma[t2].d);
}
t1=p1,t2=p2;
for(int i=;i<=c;i++){
t1=ma[t1].r;t2=ma[t2].r;
swap(ma[t1].d,ma[t2].d);
}
for(int i=;i<=l;i++){
t1=ma[t1].d;t2=ma[t2].d;
swap(ma[t1].r,ma[t2].r);
}
}
int p=;
for(int i=;i<=n;i++){
p=ma[p].d;
for(int j=,q=p;j<=m;j++){
q=ma[q].r;
cout<<ma[q].v<<" ";
}
cout<<endl;
}
}

JZOJ 5281 钦点的更多相关文章

  1. JZOJ.5281【NOIP2017模拟8.15】钦点

    Description

  2. hdu 5281 Senior's Gun

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5281 Senior's Gun Description Xuejiejie is a beautifu ...

  3. HDU 5281 Senior's Gun (贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5281 贪心题目,但是看看我的博客里边相关贪心的题解实在是少的可怜,这里就写出来供大家一起探讨. 题意还 ...

  4. (jzoj snow的追寻)线段树维护树的直径

    jzoj snow的追寻 DFS序上搞 合并暴力和,记录最长链和当前最远点,距离跑LCA # include <stdio.h> # include <stdlib.h> # ...

  5. [jzoj]3506.【NOIP2013模拟11.4A组】善良的精灵(fairy)(深度优先生成树)

    Link https://jzoj.net/senior/#main/show/3506 Description 从前有一个善良的精灵. 一天,一个年轻人B找到她并请他预言他的未来.这个精灵透过他的水 ...

  6. [jzoj]3468.【NOIP2013模拟联考7】OSU!(osu)

    Link https://jzoj.net/senior/#main/show/3468 Description osu 是一款群众喜闻乐见的休闲软件. 我们可以把osu的规则简化与改编成以下的样子: ...

  7. [jzoj]5478.【NOIP2017提高组正式赛】列队

    Link https://jzoj.net/senior/#main/show/5478 Description Sylvia 是一个热爱学习的女孩子.       前段时间,Sylvia 参加了学校 ...

  8. [jzoj]1115.【HNOI2008】GT考试

    Link https://jzoj.net/senior/#main/show/1115 Description 申准备报名参加GT考试,准考证号为n位数X1X2X3...Xn-1Xn(0<=X ...

  9. [jzoj]2538.【NOIP2009TG】Hankson 的趣味题

    Link https://jzoj.net/senior/#main/show/2538 Description Hanks 博士是BT (Bio-Tech,生物技术) 领域的知名专家,他的儿子名叫H ...

随机推荐

  1. python_69_内置函数1

    #abs()取绝对值 ''' all(iterable) Return True if all elements of the iterable are true (or if the iterabl ...

  2. 19课 Vue第二节

    事件修饰符 stop 禁止冒泡once 单次事件prevent 阻止默认事件native 原生事件(组件)keycode|name 筛选按键   组合键 : @keydown.ctrl.enter s ...

  3. Vue之Vue-touch的使用

    最近项目中,有的页面发现设置返回键看起来怪怪的,感觉与整体不协调,于是就考虑使用手势滑动事件来实现返回功能~ 开叉查阅资料~找到了vue-touch,使用起来可谓是简单粗暴啊,适合我这样的快速开发人员 ...

  4. madplay移植

    移植前需求准备: a. 源码包: 1. libid3tag-0.15.1b.tar.gz 2. libmad-0.15.1b.tar.gz 3. madplay-0.15.2b.tar.gz 4. z ...

  5. 【NTT】loj#6261. 一个人的高三楼

    去年看过t老师写这题博客:以为是道神仙题 题目大意 求一个数列的$k$次前缀和.$n\le 10^5$. 题目分析 [计数]cf223C. Partial Sums 加强版.注意到最后的式子是$f_i ...

  6. 更改 Linux 语言为中文

    查看当前系统语言环境:    echo $LANG 查看安了哪些中文语言包    locale -a |grep "zh_CN" 没有输出,说明没有安装,输入下面的命令安装     ...

  7. Springboot 入门创建hello world1!

    1.首先使用工具是Eclipse,安装插件,点击“Help”-“Eclipse Marketplace...”, 一步步直接Ok,等待安装完成 2.创建Springboot项目 到此 就创建成功了 3 ...

  8. git提交时报错 permission denied

    git push 时报错:permission denied xxx 目前很多解决办法是生成公钥和秘钥,这种方法安全可靠,比较适用于一台电脑对应一个git账户,但是多个账户在同一台电脑上提交使用git ...

  9. HTML5/CSS3 第一章基础

    HTML5/CSS3基础 1. HTML 1.1 什么是HTML HTML是用来制作网页的标记语言 HTML是Hypertext Markup Language的英文缩写,即超文本标记语言 HTML语 ...

  10. Codeforces:68A-Irrational problem(暴力大法好)

    A- Irrational problem p Time Limit: 2000MS Memory Limit: 262144K 64bit IO Format: %I64d& %I64 De ...