using namespace std;
int main()
{
int t,n,m,M[1000]={0},N[1000]={0},i,j,k=0,l,c[1000]={0},a[1000]={0};
cin>>t; //Number of TestCases//
while(t--)
{
k=0;
j=1;
k=1;
cin>>n>>m; //Number of jobs,and Number of jobs done//
for(i=1;i<=n;i++) //assigning all the jobs value "1"//
{
N[i]=1;
}
for(i=1;i<=m;i++) //Reading index of jobs done//
{
cin>>M[i];
}
for(i=1;i<=m;i++) //assigning values "0" to jobs done//
{
N[M[i]]=0;
}
/*
for(i=1;i<=n;i++)
{
cout<<N[i]<<" ";
}
*/
for(i=1;i<=n;i++)
{
cout<<N[i]<<" ";
if(N[i]==1)
{
k++;
if(k%2==0)
{
a[j]=i;
j++;
}
else
{
c[l]=i;
l++;
}
}
}
i=1;
while(c[i]!=0)
{
cout<<c[i]<<" ";
i++;
}
i=1;
while(a[i]!=0)
{
cout<<a[i]<<" ";
i++;
}
}
return 0;
}
I am not getting correct output, i have debugged it many times through many ways but of no use,please help.