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 1033. Labyrinth

Help! My program always gets WA!
Posted by abc 16 Oct 2002 08:20
Is there always a path from the top left corner to the bottom right
corner?
Attached is my program which gets WA. Can anyone give me some tests
(preferably those tests that make my program produce wrong answer)?

#include <stdio.h>
char map[34][34],v[34][34];
int n,count;
const int x[4]={-1,0,1,0};
const int y[4]={0,1,0,-1};

void dfs(int i,int j){
    int k;
    v[i][j]=1;
    for(k=0;k<4;k++){
        if(i+x[k]<0 || i+x[k]>=n || j+y[k]<0 || j+y[k]>=n ||
map[i+x[k]][j+y[k]]=='#')
            count++;
        else if(!v[i+x[k]][j+y[k]])
            dfs(i+x[k],j+y[k]);
    }
}
void main(){
    int i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s",map[i]);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            v[i][j]=0;
    count=0L;
    dfs(0,0);
    printf("%d",9*(count-4));
}
Re: Help! My program always gets WA!
Posted by RealProgrammers 28 Oct 2002 11:00
Try this map.
3
.#.
##.
...

108
Thank you very much! I get AC!
Posted by abc 29 Oct 2002 12:51
Re: Help! My program always gets WA!
Posted by SSS 31 Dec 2005 14:35
AC!  Thank you a lot!