Here 's my solution to The Selling Tickets problem in May long challenge…I have been constantly getting wrong answer for this problem…pls somebody help…
#include<stdio.h>
int main()
{
int q[200],choice[500][2],n,m,i,t,j,k,s,count,count1=0,flag;
scanf("%d",&t);
while(count1<=t)
{
printf("\n");
scanf("%d",&n);
scanf("%d",&m);
count=0;flag=1;
//initialising the status array
for(i=0;i<n;i++)
{
q[i]=i;
}
for(i=0;i<m;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&choice[i][j]);
}
}
for(i=0;i<n;i++)
{
if(choice[0][0]==i+1)
break;
}
q[i]=-1;
count++;
for(j=1;j<m;j++)
{k=0;
while(k<2)
{
for(s=0;s<n;s++)
{
if(choice[j][k]==s+1)
{
if(q[s]!=-1)
{
q[s]=-1;
count++;
flag=0;
break;
}
k++;
s=-1;
}
}
if(flag==0)
break;
}
}
printf("\n %d",count);
count1++;
}
return 0;
}