|
|
back to boardCommon BoardAHHH!!! Could.... 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.... 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!! Thanks a lot xyz!!! :) |
|
|