-
Notifications
You must be signed in to change notification settings - Fork 3
/
CCC14S2.java
51 lines (50 loc) · 1.63 KB
/
CCC14S2.java
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
/**
* CCC '14 S1 - Party Invitation
* Question type: Implementation
* 500/500 on DMOJ
* Question URL: https://dmoj.ca/problem/ccc14s2
* @author Tommy Pang
*/
public class CCC14S2 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st1, st2;
public static void main(String[] args) throws IOException {
int N = Integer.parseInt(br.readLine());
Map<String, String> map = new HashMap<>();
st1 = new StringTokenizer(br.readLine());
st2 = new StringTokenizer(br.readLine());
for (int i = 0; i < N; i++) {
String a = st1.nextToken();
String b = st2.nextToken();
if (a.equals(b)){
System.out.println("bad");
return;
}
if (!map.containsKey(a) && !map.containsKey(b)) {
map.put(a, b);
map.put(b, a);
}
else {
if (map.containsKey(a)) {
if (!map.get(a).equals(b)) {
System.out.println("bad");
return;
}
}
else {
if (!map.get(b).equals(a)) {
System.out.println("bad");
return;
}
}
}
}
System.out.println("good");
}
}