ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1386. Maze

why it is wrong? maybe i dont understansd problem?
Posted by Rage 25 Sep 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;
}
Tests
Posted by Rage 25 Sep 2005 03:12
Mayby someone gives me testcases. Thanks in advance!
Re: Tests
Posted by Mithril 26 Sep 2005 11:24
ci=a[c[k]][ci][cj][0];   --- ci changed here
cj=a[c[k]][ * ci * ][cj][1];


: )


Edited by author 26.09.2005 11:28
Thanks
Posted by Rage 26 Sep 2005 16:19
Thanks a lot! That silly mistake make me crazy :)