-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTH1TapHopSoNguyen.java
More file actions
77 lines (77 loc) · 1.97 KB
/
TH1TapHopSoNguyen.java
File metadata and controls
77 lines (77 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package JAVA;
import java.util.*;
/**
*
* @author khanh
*/
public class TH1TapHopSoNguyen {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
List<Integer> a=new ArrayList<Integer>();
List<Integer> b=new ArrayList<Integer>();
int[] aa=new int[2000];
int[] bb=new int[2000];
for(int i=0;i<n;i++){
int xx=sc.nextInt();
if(aa[xx]==0){
a.add(xx);
aa[xx]=1;
}
}
for(int i=0;i<m;i++){
int xx=sc.nextInt();
if(bb[xx]==0){
b.add(xx);
bb[xx]=1;
}
}
Collections.sort(a);
Collections.sort(b);
List<Integer> abz=new ArrayList<Integer>();
List<Integer> ab=new ArrayList<Integer>();
List<Integer> ba=new ArrayList<Integer>();
for(int i:a){
int cc=0;
for(int j:b){
if(i==j){
abz.add(i);
cc=1;
break;
}
}
if(cc==0){
ab.add(i);
}
}
for(int i:b){
int cc=0;
for(int j:a){
if(i==j){
cc=1;
break;
}
}
if(cc==0){
ba.add(i);
}
}
for(int i:abz){
System.out.print(i+" ");
}
System.out.println();
for(int i:ab){
System.out.print(i+" ");
}
System.out.println("");
for(int i:ba){
System.out.print(i+" ");
}
System.out.println();
}
}