why it is wrong? maybe i dont understansd problem?
Послано
Rage 25 сен 2005 03:02
I got WA on test 3.
I just run over all positions from which player can start game and then perform list of instruction.
#include<stdio.h>
#define FOR(i,n) for(i=0;i<(n);i++)
int s,i,j,n,m,k,ci,cj,cnt;
int a[4][110][110][2];
bool ans[110][110];
int c[4010];
int main(void)
{
scanf("%d %d",&n,&m);
FOR(k,4)
FOR(i,n)FOR(j,m)
{
scanf("%d %d",&a[k][i][j][0],&a[k][i][j][1]);
a[k][i][j][0]--;
a[k][i][j][1]--;
}
scanf("%d",&s);
FOR(k,s){scanf("%d",&c[k]);c[k]--;}
memset(ans,0,sizeof(ans));
FOR(i,n)FOR(j,m)
{
ci=i;cj=j;
FOR(k,s)
{
ci=a[c[k]][ci][cj][0];
cj=a[c[k]][ci][cj][1];
}
ans[ci][cj]=1;
}
cnt=0;
FOR(i,n)FOR(j,m)if(ans[i][j])cnt++;
printf("%d\n",cnt);
FOR(i,n)FOR(j,m)if(ans[i][j])printf("%d %d\n",i+1,j+1);
return 0;
}