825 - Walking on the Safe Side

All about problems in Volume VII. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Re: 825 - Walking on the Safe Side

Postby rmaggon » Wed Mar 30, 2011 8:38 am

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";
}
}
rmaggon
New poster
 
Posts: 1
Joined: Wed Mar 30, 2011 8:34 am

Re: 825 - Walking on the Safe Side

Postby SyFy » Mon Jul 02, 2012 10:28 pm

last line of output should be an empty line :evil:
SyFy
New poster
 
Posts: 13
Joined: Tue Jun 19, 2012 12:16 pm
Location: Russia, Vladimir

Previous

Return to Volume VIII

Who is online

Users browsing this forum: No registered users and 1 guest