HDELIVER: Need help

#include <stdio.h>
void road(int Froad[][1001],int A,int B,int *row);
int check(int Froad[][1001],int X,int Y,int row);

int main(void)
{
	int T,N,M,A,B,X,Y,Q,i,j,row,col,Froad[110][1001];
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d",&N,&M);
		scanf("%d%d",&Froad[0][1],&Froad[0][2]);
		Froad[0][0] = 2;
		row  = 1;
		M -=1;
		while(M--)
		{
			scanf("%d%d",&A,&B);
			road(Froad,A,B,&row);
		}				
		scanf("%d",&Q);
		while(Q--)
		{
			scanf("%d%d",&X,&Y);
			if(X==Y)
				printf("YO\n");
			else
				if(check(Froad,X,Y,row)==1)
					printf("YO\n");
				else
					printf("NO\n");
		}
	}
}
void road(int Froad[][1001],int A,int B,int *row)
{
	int i,j;
	for(i=0;i<*row;i++)
		for(j=1;j<=Froad[i][0];j++)
		{
			if(A == Froad[i][j])
			{
				Froad[i][0] +=1;
				Froad[i][Froad[i][0]] = B;
				return ;
			}
			if(B == Froad[i][j])
			{
				Froad[i][0] +=1;
				Froad[i][Froad[i][0]] = A;
				
				return ;
			}
		}
	Froad[*row][0] =2;
	Froad[*row][1] = A;
	Froad[*row][2] = B;
	*row +=1;
	return ;
}
int check(int Froad[][1001],int X,int Y,int row)
{
	int flag,i,j;
	for(i=0;i<row;i++)
	{
		flag =0;
		for(j=1;j<=Froad[i][0];j++)
		{
			if(X == Froad[i][j]||Y == Froad[i][j])
			{
				if(flag==0)
					flag=1;
				else
					return flag;
			}
		}
	}
	return flag=0;
}

please describe the approach you used to solve this problem.

You can discuss the problem here.

I can’t get AC.can anybody help me?

Please select your whole code and mark it as code segment by clicking on 101010 image at the top of the post editor. Currently few character like * which are reserved for markdown are lost due to this and it makes the code unreadable. If that doesn’t help paste your code elsewhere like pastebin/ideone and post a link here, I usually recommend this for lengthy codes as that keeps the post length small. In this particular case since it is a submission on codechef itself you can simple give the link of your submission CodeChef: Practical coding for everyone

1 Like