-
Notifications
You must be signed in to change notification settings - Fork 3
/
CCC06S2.java
34 lines (34 loc) · 1.21 KB
/
CCC06S2.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
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 '06 S2 - Attack of the CipherTexts
* Question type: Implementation
* 5/5 on DMOJ
* @author Tommy Pang
*/
public class CCC06S2 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static Map<String, String> map = new HashMap<>();
public static void main(String[] args) throws IOException{
String plaintext = br.readLine();
String ciphertext = br.readLine();
String outputText = br.readLine();
for (int i = 0; i < plaintext.length(); i++) {
String plainChar = String.valueOf(plaintext.charAt(i));
String cipherChar = String.valueOf(ciphertext.charAt(i));
if (!map.containsKey(cipherChar)){
map.put(cipherChar, plainChar);
}
}
String ans = "";
for (int i = 0; i < outputText.length(); i++) {
ans += map.getOrDefault(String.valueOf(outputText.charAt(i)), ".");
}
System.out.println(ans);
}
}