This is my code... I am getting WA but my code is sattisfying all the test cases given in one of the post on this ques....plz help me out
#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--;
}
int main()
{
int t;
cin>>t;
while(t--)
{
ans=0;
ReadCase();
cal(0,0);
cout<<ans;
if(t!=0)
cout<<"\n\n\n";
}
}
