SWEA_1229) 암호문2
SWEA
# D3
1229) 암호문2 (19.10.21)
문제 링크 (SW Expert Academy)
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
|
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer tk;
for(int test=1; test<=10; test++) {
int n = Integer.parseInt(br.readLine());
ArrayList<Integer> list = new ArrayList<>();
tk = new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) {
list.add(Integer.parseInt(tk.nextToken()));
}
int m = Integer.parseInt(br.readLine());
int cnt = 0;
tk = new StringTokenizer(br.readLine());
while(cnt<m) {
String s = tk.nextToken();
if(s.equals("I")) {
int x = Integer.parseInt(tk.nextToken());
int y = Integer.parseInt(tk.nextToken());
for(int p=0;p<y;p++) {
list.add(x, Integer.parseInt(tk.nextToken()));
x = x+1;
}
}
else if(s.equals("D")) {
int x = Integer.parseInt(tk.nextToken());
int y = Integer.parseInt(tk.nextToken());
for(int p=0;p<y;p++) {
list.remove(x);
}
}
cnt = cnt+1;
}
bw.write("#" + test + " ");
for(int i=0;i<10;i++) {
bw.write(list.get(i)+" ");
}
bw.write("\n");
}
bw.flush();
bw.close();
}
}
| cs |
댓글
댓글 쓰기