SWEA 1228暗号文1



これはLinkedListを用いて所与の条件を実現する問題である.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Solution {
	static BufferedReader br;
	static BufferedWriter bw;
	static StringTokenizer st;
	static LinkedList<Integer> lkdList;

	public static void main(String[] args) throws IOException {

		br = new BufferedReader(new InputStreamReader(System.in));
		bw = new BufferedWriter(new OutputStreamWriter(System.out));
		int T = 10;
		for (int tc = 1; tc <= T; tc++) {
			int N = Integer.parseInt(br.readLine());
			st = new StringTokenizer(br.readLine(), " ");
			lkdList = new LinkedList<>();
			for (int i = 0; i < N; i++) {
				lkdList.offer(Integer.parseInt(st.nextToken()));
			}
			// 명령어 입력받기
			N = Integer.parseInt(br.readLine());
			st = new StringTokenizer(br.readLine(), " ");
			while (st.hasMoreElements()) {
				st.nextToken();
				int x = Integer.parseInt(st.nextToken());
				int y = Integer.parseInt(st.nextToken());

				for (int i = x; i < x + y; i++) {
					lkdList.add(i, Integer.parseInt(st.nextToken()));
				}
			}					
			bw.write(String.format("#%d", tc));			
			for(int i = 0; i < 10; i++) {
				bw.write(String.format(" %d", lkdList.get(i)));
			}
			bw.write("\n");
		}
		bw.flush();
		bw.close();
	}

}