fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t, m, n, job[1002], k, a=1, count;
  7. cin>>t;
  8. while(t--) {
  9. cin>>m>>n;
  10. for(int i=0; i<1002; i++) job[i]=false;
  11. for(int i=1; i<=m; i++) job[i]=true;
  12. for(int i=1; i<=n; i++) {
  13. cin>>k; job[k]=false;
  14. }
  15. for(int i=1, count=1; i<=m; i++) {
  16. if(job[i]&&(count%2)) cout<<i<<" ";
  17. if(job[i]) count++;
  18. }
  19. cout<<endl;
  20. for(int i=1, count=1; i<=m; i++) {
  21. if(job[i]&&(count%2==0)) cout<<i<<" ";
  22. if(job[i]) count++;
  23. }
  24. cout<<endl;
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 3344KB
stdin
3
6 3
2 4 1
3 2
3 2
8 2
3 8
stdout
3 6 
5 
1 

1 4 6 
2 5 7