알고리즘 문제 풀이

SWEA 암호문 1: 자바

superbono 2021. 2. 8. 23:23

swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14w-rKAHACFAYD&categoryId=AV14w-rKAHACFAYD&categoryType=CODE&problemTitle=%EC%95%94%ED%98%B8%EB%AC%B8&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

그냥 LinkedList 연습 문제다

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

public class swea암호문1 {
	static int N, M, x, y, s;
	static LinkedList <Integer> al, newAl;
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int tc = 1; tc <= 1; tc++) {
			//0 ~ 999999까지 니까 integer 가능
			al = new LinkedList<Integer>(); 
			N = sc.nextInt();
			
			// 원본 암호문 입력 
			for (int i = 0; i < N; i++) {
				al.add(sc.nextInt());
			}
			// 명령어의 개수
			M = sc.nextInt();
			for (int i = 0; i < M; i++) {
				newAl = new LinkedList<Integer>(); 
				
				sc.next(); // I 먹고 버림
				x = sc.nextInt();
				y = sc.nextInt();
				for (int j = 0; j < y; j++) {
					newAl.add(sc.nextInt());
				}
				
				for (int j = y -1; j >= 0; j--) {
					al.add(x, newAl.get(j));
				}
			}
			System.out.print("#" + tc + " ");
			for (int i = 0; i < 10; i++) {
				System.out.print(al.get(i) + " ");
			}
			System.out.println();
		}
	}
}