fork(3) download
  1. import java.io.*;
  2. public class Main{
  3. public static void main(String[] args) throws IOException{
  4. int t=Integer.parseInt(br.readLine());
  5. boolean a[];
  6. for(int i=0;i<t;i++){
  7. // a=new boolean[1001];
  8. String s=br.readLine();
  9. String s1[]=s.split(" ");
  10. int n=Integer.parseInt(s1[0]);
  11. int m=Integer.parseInt(s1[1]);
  12. a=new boolean[n+1];
  13. s=br.readLine();
  14. String d[]=s.split(" ");
  15. int j=0;
  16. while(j<=(s.length())/2){
  17. a[Integer.parseInt(d[j])]=true;
  18. j++;
  19. }
  20. j=1;
  21. int done=1;
  22. while(j<=n){
  23. if(a[j]==false){
  24. if(done==1){
  25. a[j]=true;
  26. System.out.print(j+" ");
  27. done=0;
  28. }else{
  29. done=1;
  30. }
  31. }
  32. j++;
  33. }
  34. System.out.println();
  35. j=1;
  36. while(j<=n){
  37. if(a[j]==false)
  38. System.out.print(j+" ");
  39. j++;
  40. }
  41. System.out.println();
  42.  
  43. }
  44.  
  45. }
  46. }
Success #stdin #stdout 0.07s 380224KB
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