Algorithm/SWEA

[swexpert] 1228. 암호문1

반응형

[swexpert] 1228. 암호문1


문제 출처

https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14w-rKAHACFAYD&categoryId=AV14w-rKAHACFAYD&categoryType=CODE




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
58
59
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
public class Solution_1228_SW문제해결기본8일차_암호문1_김규석 {
    
    public static void main(String[] args) throws NumberFormatException, IOException {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        for (int i = 1; i <= 10; i++) { // 테스트 케이스 반복
            
            ArrayList<String> strArr = new ArrayList<String>(); // 저장할 arraylist 생성
            
            int num = Integer.parseInt(br.readLine()); // 숫자 입력
            
            String[] str = new String[num]; // 숫자만큼 string 생성
            
            str = br.readLine().split(" ");
            
            for (int j = 0; j < str.length; j++) {
                strArr.add(str[j]);
            }
            
            
            int orderNum = Integer.parseInt(br.readLine());
            
            String[] newStr = new String[orderNum];
            
            newStr = br.readLine().split("I "); // split으로 필요한 부분만 저장
            
            for (int j = 0; j < newStr.length; j++) {
                newStr[j] = newStr[j].trim(); // 공백 제거
            }
            
            String[] chk = new String[newStr.length];
            
            for (int j = 1; j <= orderNum; j++) {
                chk = newStr[j].split(" ");
                
                int index = Integer.parseInt(chk[0]); // 첫번째 인자 값으로 인덱스 가져오기
                
                for (int k = chk.length-1; k > 1; k--) { // 해당 인덱스를 list에 추가
                    strArr.add(index, chk[k]);
                }
            }
            
            
            System.out.print("#"++ " ");
            for (int j = 0; j < 10; j++) {
                System.out.print(strArr.get(j) + " ");
            }
            System.out.println();
        }
    }
 
}
 
cs


반응형

'Algorithm > SWEA' 카테고리의 다른 글

[swexpert 2819] 격자판의 숫자 이어 붙이기  (0) 2019.02.17
[swexpert] 1224. 최단 경로  (2) 2019.02.12
[swexpert] 1210. Ladder1  (0) 2019.01.14
[swexpert] 1225. 암호생성기  (0) 2019.01.11
[swexpert] 1206. View  (0) 2019.01.11