#include<cstdio>
#include<algorithm>
using namespace std
;
struct node
{
int x
, y
;
node(int x
=0,int y
=0):x(x
),y(y
){};
node
operator = (node
& b
){
int t
=this->x
;
this->x
=b
.x
;
b
.x
=t
;
t
=this->y
;
this->y
=b
.y
;
b
.y
=t
;
}
void p()
{
this->x
=0;
this->y
=0;
}
};
int map
[100][100],an
[100][100];
int n
,m
;
void copy(int x
,int y
,int x1
,int y1
)
{
int t
;
t
=map
[x
][y
];
map
[x
][y
]=map
[x1
][y1
];
map
[x1
][y1
]=t
;
}
void del(int c
,char type
)
{
if(type
=='C')
{
for(int i
=c
;i
<=m
;i
++)
{
for(int k
=1;k
<=n
;k
++)
{
map
[k
][i
]=map
[k
][i
+1];
}
}
m
-=1;
}
if(type
=='R')
{
for(int i
=c
;i
<=n
;i
++)
{
for(int k
=1;k
<=m
;k
++)
{
map
[i
][k
]=map
[i
+1][k
];
}
}
n
-=1;
}
}
void inp(int c
,char type
)
{
if(type
=='C')
{
for(int i
=m
;i
>=c
;i
--)
{
for(int k
=1;k
<=n
;k
++)
{
map
[k
][i
+1]=map
[k
][i
];
}
}
for(int k
=1;k
<=n
;k
++)
map
[k
][c
]=0;
m
+=1;
}
if(type
=='R')
{
for(int i
=n
;i
>=c
;i
--)
{
for(int k
=1;k
<=m
;k
++)
{
map
[i
+1][k
]=map
[i
][k
];
}
}
for(int k
=1;k
<=m
;k
++)
map
[c
][k
]=0;
n
+=1;
}
}
int main()
{
int o
=0;
while(scanf("%d%d",&n
,&m
)==2&&n
)
{
for(int i
=1;i
<=70;i
++)
{
for(int k
=1;k
<=70;k
++)
{
map
[i
][k
]=0;
an
[i
][k
]=0;
}
}
for(int i
=1;i
<=n
;i
++)
{
for(int k
=1;k
<=m
;k
++)
{
map
[i
][k
]=i
*10000+k
;
}
}
int op
;
char cur
[10];
scanf("%d",&op
);
while(op
--)
{
getchar();
scanf("%s",cur
);
if(cur
[0]=='E')
{
int x1
,x2
,y1
,y2
;
scanf("%d%d%d%d",&x1
,&y1
,&x2
,&y2
);
copy(x1
,y1
,x2
,y2
);
}
else if(cur
[0]=='D')
{
int i
;
int cu
[100],p
=1;
scanf("%d",&i
);
for(int j
=1;j
<=i
;j
++)
{
scanf("%d",&cu
[j
]);
}
sort(cu
+1,cu
+1+i
);
while(i
--)
{
del(cu
[p
]-p
+1,cur
[1]);
p
++;
}
}
else
{
int i
,cu
[100],p
=1;
scanf("%d",&i
);
for(int j
=1;j
<=i
;j
++)
{
scanf("%d",&cu
[j
]);
}
sort(cu
+1,cu
+1+i
);
while(i
--)
{
inp(cu
[p
]+p
-1,cur
[1]);
p
++;
}
}
}
for(int i
=1;i
<=n
;i
++)
{
for(int k
=1;k
<=m
;k
++)
{
if(map
[i
][k
]%10000!=0){
an
[map
[i
][k
]/10000][map
[i
][k
]%10000]=i
*10000+k
;
}
}
}
int k
;
scanf("%d",&k
);
int x
,y
;
if(o
>0)printf("\n");
printf("Spreadsheet #%d\n",++o
);
for(int i
=1;i
<=k
;i
++)
{
scanf("%d%d",&x
,&y
);
if(an
[x
][y
]/10000)printf("Cell data in (%d,%d) moved to (%d,%d)\n",x
,y
,an
[x
][y
]/10000,an
[x
][y
]%10000);
else printf("Cell data in (%d,%d) GONE\n",x
,y
);
}
}
return 0;
}
转载请注明原文地址:https://tech.qufami.com/read-19758.html