import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m = "";
ArrayList<Integer> arr1, arr2;
while ((m = br.readLine()) != null) {
arr1 = new ArrayList<Integer>();
StringTokenizer st = new StringTokenizer(m);
int n = st.countTokens();
for (int i = 0; i < n; i++) {
arr1.add(Integer.parseInt(st.nextToken()));
}
arr2 = new ArrayList<Integer>();
st = new StringTokenizer(br.readLine());
n = st.countTokens();
for (int i = 0; i < n; i++) {
arr2.add(Integer.parseInt(st.nextToken()));
}
if (arr1.size() < arr2.size()) {
int count = 0;
for (int i = 0; i < arr1.size(); i++) {
if (arr2.contains(arr1.get(i))) {
count++;
}
}
if (count == arr1.size()) {
sb.append("A is a proper subset of B\n");
} else if (count == 0) {
sb.append("A and B are disjoint\n");
} else {
sb.append("I'm confused!\n");
}
} else if (arr1.size() > arr2.size()) {
int count = 0;
for (int i = 0; i < arr2.size(); i++) {
if (arr1.contains(arr2.get(i))) {
count++;
}
}
if (count == arr2.size()) {
sb.append("B is a proper subset of A\n");
} else if (count == 0) {
sb.append("A and B are disjoint\n");
} else {
sb.append("I'm confused!\n");
}
} else {
int count = 0;
for (int i = 0; i < arr2.size(); i++) {
if (arr1.contains(arr2.get(i))) {
count++;
}
}
if (count == arr2.size()) {
sb.append("A equals B\n");
} else if (count == 0) {
sb.append("A and B are disjoint\n");
} else {
sb.append("I'm confused!\n");
}
}
}
System.out.print(sb);
}
}
No comments:
Post a Comment