Cant find the error , help please


int main(void) {
	int n,i,r0,c0,sp;
	scanf("%d",&n);
	int a[n][2];
	for(i=0;i<n;i++)
	{
	    scanf("%d %d",&a[i][0],&a[i][1]);
	}
	int ans[50][2]=
	{
	    1,1,
	    2,2,
	    1,3,
	    2,4,
	    3,5,
	    4,6,
	    5,7,
	    6,8,
	    7,7,
	    8,6,
	    7,5,
	    6,4,
	    5,3,
	    4,2,
	    3,1,
	    2,2,
	    3,3,
	    2,4,
	    1,5,
	    2,6,
	    3,7,
	    4,8,
	    5,7,
	    6,6,
	    7,5,
	    8,4,
	    7,3,
	    6,2,
	    5,1,
	    4,2,
	    3,3,
	    4,4,
	    3,5,
	    2,6,
	    1,7,
	    2,8,
	    3,7,
	    4,6,
	    5,5,
	    6,4,
	    7,3,
	    8,2,
	    7,1,
	    6,2,
	    5,3,
	    4,4,
	    5,5,
	    6,6,
	    7,7,
	    8,8
	};
	for(i=0;i<n;i++)
	{   
	    r0=a[i][0];
	    c0=a[i][1];
	    for(sp=0;sp<50;sp++)
	    {
	        if((r0==ans[sp][0])&&(c0==ans[sp][1]))
	                break;
	    }
	    
	    printf("49\n");
	    
	    for(i=sp+1;i<50;i++)
	     printf("%d %d\n",ans[i][0],ans[i][1]);
	     for(i=0;i<sp;i++)
	     printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}

link to question - ADASHOP2 Problem - CodeChef
link to my submission - CodeChef: Practical coding for everyone
It gives a partially correct answer.

Note that each cell may be visited multiple times and it is not necessary to return to the starting point.

It is not printing 1 1.

for this test case
1
1 1

@tmatheena but in the question it is said that we need not print the initial point also at the end of path it need not return to starting point

Note that each cell may be visited multiple times and it is not necessary to return to the starting point.

. we need to only specify the coordinates of where its going in the path. and this solution passed the subtask , subtask was 1 1. :cry:

yes missed that.
It will be much time consuming to debug this.
this is my solution.
https://www.codechef.com/viewsolution/30080666
for subtask 2
Just move to 1,1 first .Then move same steps done for subtask 1.

1 Like