题目链接:点击打开链接
#include <stdio.h>
#include <string.h>
#include <time.h>
#define maxn 10000
struct opera{
char ope_1[10];
int ope_2[10];
}opera[maxn];
int ope(int &x1,int &y1,int n1)
{
for(int i=0;i<n1;i++)
{
int dr=0;
int dc=0;
if(opera[i].ope_1[0]=='D')
{
if(opera[i].ope_1[1]=='R')
for(int l=1;l<=opera[i].ope_2[0];l++)
{
if(x1==opera[i].ope_2[l])
{
return 0;
//printf("@2:%d\n",x1);
}
else if(x1>opera[i].ope_2[l])
dr--;
//printf("@3:%d%d\n",x1,y1);
}
else
for(int l=1;l<=opera[i].ope_2[0];l++)
{
if(y1==opera[i].ope_2[l])
return 0;
else if(y1>opera[i].ope_2[l])
dc--;
}
}
else if(opera[i].ope_1[0]=='I')
{
if(opera[i].ope_1[1]=='R')
for(int l=1;l<=opera[i].ope_2[0];l++)
{
if(x1>=opera[i].ope_2[l])
dr++;
}
else
for(int l=1;l<=opera[i].ope_2[0];l++)
{
if(y1>=opera[i].ope_2[l])
dc++;
}
}
else
{
if((x1==opera[i].ope_2[0]&&y1==opera[i].ope_2[1]))
{
x1=opera[i].ope_2[2];
y1=opera[i].ope_2[3];
}
else if(x1==opera[i].ope_2[2]&&y1==opera[i].ope_2[3])
{
x1=opera[i].ope_2[0];
y1=opera[i].ope_2[1];
}
}
x1+=dr;
y1+=dc;
}
return 1;
}
int main()
{
//freopen("data.txt","r",stdin);
//freopen("printf.txt","w",stdout);
int r,c,n1,n2,x1,y1,x2,y2,kase=1;
while(scanf("%d%d%d",&r,&c,&n1)&&r)
{
memset(opera,0,sizeof(opera));
for(int i=0;i<n1;i++)
{
scanf("%s",opera[i].ope_1);
if(opera[i].ope_1[0]!='E')
{
scanf("%d",&opera[i].ope_2[0]);
for(int j=1;j<=opera[i].ope_2[0];j++)
scanf("%d",&opera[i].ope_2[j]);
}
else
for(int j=0;j<4;j++)
scanf("%d",&opera[i].ope_2[j]);
}
scanf("%d",&n2);
if(kase>1)
printf("\n");
printf("Spreadsheet #%d\n", kase++);
while(n2--)
{
scanf("%d%d",&x1,&y1);
//printf("@1:%d/n",x1);
int x2=x1,y2=y1;
if(!ope(x1,y1,n1))
printf("Cell data in (%d,%d) GONE\n", x2, y2);
else
printf("Cell data in (%d,%d) moved to (%d,%d)\n", x2, y2, x1, y1);
}
}
//printf("Time used=%2.3f\n",(double)clock()/CLOCKS_PER_SEC);
}