728x90
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14w-rKAHACFAYD
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
문제)
풀이)
LinkedList를 이용한다면 간단한 문제이다.
중간에 자주 추가가 이루어져서 linked list를 이용했다.
명령어를 만나고, start부터 end index 까지 삽입하는 방법을 사용했다.
그 후 완성되면 앞에서부터 10개 출력하면 끝!
//import java.io.FileInputStream;
import java.util.LinkedList;
import java.util.Scanner;
public class Solution_D3_1228_암호문1 {
public static void main(String[] args) throws Exception {
//System.setIn(new FileInputStream("input.txt"));
Scanner sc = new Scanner(System.in);
for(int test_case = 1; test_case <= 10; test_case++){
int N = sc.nextInt();
LinkedList<Integer> key = new LinkedList<>();
for(int i=0; i<N; i++) {
key.add(sc.nextInt());
}
int cmdNum = sc.nextInt();
for(int i=0; i<cmdNum; i++) {
String str = sc.next();
int start = sc.nextInt();
int end = sc.nextInt();
for(int j=start; j<=start+end-1; j++) {
key.add(j, sc.nextInt());
}
}
System.out.print("#"+test_case+ " ");
for(int k=0; k<10; k++) {
System.out.print(key.get(k) + " ");
}
System.out.println();
}
sc.close();
}
}
728x90
'코테 > SWEA' 카테고리의 다른 글
SWEA 9229 한빈이와 SpotMart (0) | 2022.08.20 |
---|---|
SWEA 1225. 암호생성기(JAVA) (0) | 2022.08.16 |
SWEA 2001. 파리퇴치(JAVA, Python) (0) | 2022.08.16 |
SWEA 1218. 괄호 짝짓기(JAVA) (0) | 2022.08.12 |
SWEA 2805. 농작물 수확하기(JAVA) (0) | 2022.08.12 |