Coodechef Cleaning Up Problem Code: CLEANUP Solution
Solution in C++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,m,n,i,j,t;
vector<int>ch;
vector<int>ass;
cin>>t;
while(t--)
{
cin>>n>>m;
vector<int>ar(n+10,10);
for(i=0; i<m; i++)
{
cin>>a;
ar[a]=0;
}
int r=1;
for(i=1; i<=n; i++)
{
if(ar[i]!=0)
{
if(r%2==1)
{
ch.push_back(i);
r=0;
}
else
{
ass.push_back(i);
r=1;
}
}
}
for(i=0; i<ch.size(); i++)
{
cout<<ch[i]<<" ";
}
cout<<endl;
for(i=0; i<ass.size(); i++)
{
cout<<ass[i]<<" ";
}
cout<<endl;
ch.clear();
ass.clear();
}
}
No comments