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

Common Board

AHHH!!! Could....
Posted by Miguel Angel 20 Dec 2001 10:59
Could anyone tell me what's wrong with my program...I know it's very
simple, evenmore, get WA :(

#include<iostream.h>

#define visited '+'

short N;
int   AofW;
char  lab[35][35];

void scandata()
{
 short i, j;
 cin>>N;
 for (i=0; i<N; i++)
    for (j=0; j<N; j++) cin>>lab[i][j];
}

void visit(short i, short j)
{
 if (i<0 || i==N ||
      j<0 || j==N)
 {
    AofW++;
    return;
 }
 if (lab[i][j]==visited)
        return;
 if (lab[i][j]=='#')
 {
    AofW++;
    return;
 }
 lab[i][j] = visited;
    visit(i+1,j);
    visit(i-1,j);
    visit(i,j+1);
    visit(i,j-1);
}

void processdata()
{
    AofW = 0;
    visit(0,0);
    if (lab[N-1][N-1]==visited)
    {
        if (AofW-4<0) cout<<0<<endl;
             else cout<<((AofW-4)*9)<<endl;
    }
    else
        cout<<0<<endl;
}

void main()
{
    scandata();
    processdata();
}
Re: AHHH!!! Could....
Posted by I have answers to all your questions :) 20 Dec 2001 12:00
void processdata()
{
    AofW = 0;
    visit(0,0);
    if (lab[N-1][N-1]!=visited) visit(N-1,N-1);
        cout<<((AofW-4)*9)<<endl;
}

=> ACCEPTED
What stupid i'm!!
Posted by Miguel Angel 21 Dec 2001 11:34
Thanks a lot xyz!!! :)