알고리즘/SwExpert recipe

SWEA 암호문1 [D3]

컵라면만두세트 2021. 2. 9. 21:49

 

package D3;

import java.util.LinkedList;
import java.util.Scanner;

public class 암호문1다른버전 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int tc = 1; tc<= 10; tc++) {
			int N = sc.nextInt(); // N원본 암호문의 길이
			LinkedList <Integer> list = new LinkedList<>();
			for(int i =0; i<N; i++) {
			int tmp = sc.nextInt(); //  원본 암호문 
			list.add(tmp); // 받은거 하나하나 리스트에 넣어주세요 
			}
			int K = sc.nextInt(); // 명령어의 개수 
			for(int i =0; i<K; i++) {
				//명령어의 개수만큼 돌려보자 
				String s = sc.next();// insert 그냥 문제에 주어진대로
				int idx = sc.nextInt(); // idx번째의 다음위치에 넣어줄꺼다 
				int m = sc.nextInt(); // m개의 숫자를 넣을꺼구 
				int arr[] = new int[m]; // m개의 공간만들고 , m개의 덧붙일 숫자 넣어주고
				for(int j=0; j<m; j++) {
					//m만큼 실행해서 덧붙일 숫자를 넣어주자
					arr[j] = sc.nextInt(); // arr0, arr1 이렇게 인덱스 0 번째 부터 들어가겠네
				}
				for(int j = m-1; j>=0; j--) {
					list.add(idx,arr[j]); // 원하는 인덱스에 새로 붙일 인덱스 
				}
			}
			System.out.println("#" + tc + " ");
			for(int i =0; i<10; i++) {
				System.out.println(list.get(i) + " ");
			}
			System.out.println();
			}
	}

}