-
Notifications
You must be signed in to change notification settings - Fork 0
/
Babelfish.java
40 lines (34 loc) · 930 Bytes
/
Babelfish.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
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.*;
import java.util.stream.*;
import java.io.*;
import java.math.*;
import java.text.*;
/*
* @author Theodoric Keith Lim
*/
class Babelfish {
public static void main(String[] args) {
new Babelfish();
}
Babelfish() {
answer();
}
void answer() {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
HashMap<String, String> hmap = new HashMap<>();
while (sc.hasNextLine()) {
String s = sc.nextLine();
if (s.isEmpty()) break;
String[] arr = s.split("\\s+");
hmap.put(arr[1], arr[0]);
}
while (sc.hasNextLine()) {
String s = sc.nextLine();
sb.append(hmap.containsKey(s) ? hmap.get(s) : "eh").append("\n");
}
System.out.println(sb.toString());
}
}