Hey, I am getting WA for the problem Walking on Safe side for my code written below. I have checked all test cases and formatting of output and its working fine on my pc, could anyone help plz.
Here is the problem link http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=10&problem=766&mosmsg=Submission+received+with+ID+8692538 Here is my code #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> using namespace std; int table[200][200]={}; char str[200]; int dx,dy; int ans=0; void cal(int x,int y) { if(x==dx&&y==dy) { ans++; return; } if(table[x][y+1]==0&&y<dy) { cal(x,y+1); } if(table[x+1][y]==0&&x<dx) { cal(x+1,y); } } void Reset() { int i, j; for(i = 0; i<=dx; i++) { for(j = 0; j<=dy; j++) { table[i][j] = 0; } } } void ReadCase() { int i, j; char *p; gets(str); cin>>dx>>dy; Reset(); for(i = 0; i<=dx; i++) { gets(str); p = strtok(str," "); p = strtok(NULL, " "); while(p) { j = atoi(p); table[i-1][j-1] = 1; p = strtok(NULL, " "); } } dx--; dy--; /*for(i=0;i<=dx;i++) { for(j=0;j<=dy;j++) { cout<<table[i][j]<<" "; } cout<<"\n"; }*/ } int main() { int t; cin>>t; while(t--) { ans=0; ReadCase(); cal(0,0); cout<<ans; if(t!=0) cout<<"\n\n\n"; } } -- Regards Ravi Maggon -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
