SWEA_1946) 간단한 압축 풀기
SWEA
# D2
1946) 간단한 압축 풀기 (19.10.04)
문제 링크 (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
|
import java.io.*;
import java.util.*;
class Pair{
String s;
int x;
Pair(String s, int x){
this.s = s;
this.x = x;
}
}
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));
int t = Integer.parseInt(br.readLine());
for(int i=1;i<=t;i++) {
int n = Integer.parseInt(br.readLine());
ArrayList<Pair> list = new ArrayList<Pair>();
for(int j=0;j<n;j++) {
String[] s = br.readLine().split(" ");
String p = s[0];
int q = Integer.parseInt(s[1]);
list.add(new Pair(p, q));
}
bw.write("#" + i + "\n");
int cnt = 0;
for(int u=0;u<list.size();u++) {
Pair k = list.get(u);
for(int v=0;v<k.x;v++) {
if(cnt!=0 && cnt%10==0) bw.write("\n");
bw.write(k.s+"");
cnt = cnt+1;
}
}
bw.write("\n");
}
bw.flush();
bw.close();
}
}
| cs |
댓글
댓글 쓰기