标签:logs center print enter 测试题 als font 交换 没有
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<cstdlib> #include<cstring> #include<cmath> #include<algorithm> using namespace std; template<typename T>void read(T &x) { x=0;char c=getchar(); for(;!isdigit(c);c=getchar()); for(;isdigit(c);c=getchar())x=x*10+c-‘0‘; } int n,m,q,sum[1000005],r[1000005],d[1000005],a[1005][1005]; char ch[10000005]; int pos(int down,int right) { int x=0; while(down--)x=d[x]; while(right--)x=r[x]; return x; } int main() { freopen("appoint.in","r",stdin); freopen("appoint.out","w",stdout); int i,j,k; int x1,x2,y1,y2,xx,yy,p1,p2; read(n);read(m);read(q); for(i=1;i<=n*m;i++) { scanf("%s",ch+sum[i-1]+1); sum[i]=sum[i-1]+strlen(ch+sum[i-1]+1); } for(i=1;i<=n;i++) for(j=1;j<=m;j++) a[i][j]=(i-1)*m+j; int tot=n*m; for(i=0;i<=n+1;i++) for(j=0;j<=m+1;j++) if((i||j)&&!a[i][j])a[i][j]=++tot; for(i=0;i<=n;i++) for(j=0;j<=m;j++) r[a[i][j]]=a[i][j+1], d[a[i][j]]=a[i+1][j]; while(q--) { read(x1);read(y1);read(x2);read(y2);read(xx);read(yy); int pos1=pos(x1-1,y1-1),Pos1=d[r[pos1]]; int pos2=pos(x2-1,y2-1),Pos2=d[r[pos2]]; for(i=1,p1=d[pos1],p2=d[pos2];i<=xx;i++,p1=d[p1],p2=d[p2])swap(r[p1],r[p2]); for(i=1,p1=r[pos1],p2=r[pos2];i<=yy;i++,p1=r[p1],p2=r[p2])swap(d[p1],d[p2]); pos1=Pos1;pos2=Pos2; for(i=1;i<yy;i++)pos1=r[pos1]; for(i=1;i<yy;i++)pos2=r[pos2]; for(i=0,p1=pos1,p2=pos2;i<xx;i++,p1=d[p1],p2=d[p2])swap(r[p1],r[p2]); pos1=Pos1;pos2=Pos2; for(i=1;i<xx;i++)pos1=d[pos1]; for(i=1;i<xx;i++)pos2=d[pos2]; for(i=0,p1=pos1,p2=pos2;i<yy;i++,p1=r[p1],p2=r[p2])swap(d[p1],d[p2]); } for(i=1,p1=d[0];i<=n;i++,p1=d[p1]) { for(j=1,p2=r[p1];j<=m;j++,p2=r[p2]) { for(k=sum[p2-1]+1;k<=sum[p2];k++) printf("%c",ch[k]); printf(" "); } printf("\n"); } return 0; }
标签:logs center print enter 测试题 als font 交换 没有
原文地址:http://www.cnblogs.com/huangdalaofighting/p/7406154.html