I am new in code-chef and doing some practice. I have written the solution of the BurstFire problem(Easy problem here is the link http://www.codechef.com/problems/FIRE ) It is working fine in my system but getting wrong answer in code chef here is my code
#include<stdio.h>
#define TRUE 1
#define FALSE 0
int child[11000][4];
int child_count[11000];
int save[11000];
int answer[50];
int can_prot(int s,int p)
{
int i;
if(save[s])
return FALSE;
int canp=0;
for(i=1;i<=child_count[s];i++)
{
int t=child[s][i];
if(t==p)
continue;
if(!can_prot(t,s))
canp++;
}
if(canp>1)
return FALSE;
return TRUE;
}
int main()
{
int T,temp;
int i,j,k; // loop var
int n,s,t;
scanf("%d",&T);
getchar(); // for newline
getchar(); // for new line
for(i=1;i<=T;i++)
{
scanf("%d",&n);
scanf("%d",&s);
scanf("%d",&t);
getchar(); // for newline
for(j=1;j<=n;j++)
{
scanf("%d",&child_count[j]);
for(k=1;k<=child_count[j];k++)
{
scanf("%d",&child[j][k]);
}
getchar(); // for newline
}
for(j=1;j<=11000;j++)
save[j]=FALSE;
for(j=1;j<=t;j++)
{
scanf("%d",&temp);
save[temp]=TRUE;
}
getchar();
getchar();
answer[i]=can_prot(s,s);
}
for(i=1;i<=T;i++)
{
if(i==T)
printf("%s",answer[i]?"yes":"no");
else
printf("%s\n",answer[i]?"yes":"no");
}
return 0;
}
The approach I have used is simple. Start from the bush which is on fire and then perform the same on his children if more than one children has false as output then answer is false because We can save only one bush at a time.
Am I missing some test cases please anyone suggest