-
Notifications
You must be signed in to change notification settings - Fork 7
/
Main.java
57 lines (49 loc) · 1.38 KB
/
Main.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
52
53
54
55
56
57
package basicLevel1052;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
List<String> hand = parse(in.nextLine());
List<String> eye = parse(in.nextLine());
List<String> mouth = parse(in.nextLine());
int k = in.nextInt();
for (int i = 0; i < k; i++) {
int[] num = new int[5];
num[0] = in.nextInt();
num[1] = in.nextInt();
num[2] = in.nextInt();
num[3] = in.nextInt();
num[4] = in.nextInt();
if (num[0] >= hand.size() || num[0] < 1 || num[4] >= hand.size() || num[4] < 1 || num[1] >= eye.size()
|| num[1] < 1 || num[3] >= eye.size() || num[3] < 1 || num[2] >= mouth.size() || num[2] < 1) {
System.out.println("Are you kidding me? @\\/@");
continue;
}
System.out.println(hand.get(num[0]) + "(" + eye.get(num[1]) + mouth.get(num[2]) + eye.get(num[3]) + ")"
+ hand.get(num[4]));
}
in.close();
}
public static List<String> parse(String s) {
boolean isStart = false;
List<String> list = new ArrayList<>();
String temp = "";
list.add(temp);
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '[') {
isStart = true;
} else if (s.charAt(i) == ']') {
isStart = false;
list.add(temp);
temp = "";
} else {
if (isStart) {
temp += s.charAt(i);
}
}
}
return list;
}
}