import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int[] arr = new int[N];
int M = scanner.nextInt();
for (int i = 0; i < N; i++) {
arr[i] = i+1;
}
for (int i = 0; i < M; i++) {
int left = scanner.nextInt() - 1;
int right = scanner.nextInt() - 1;
while (left < right) {
int temp = arr[left];
arr[left++] = arr[right];
arr[right--] = temp;
}
}
for (int result : arr) {
System.out.printf(result + " ");
}
}
}
'코딩 테스트 > Python - 백준 단계별로 풀어보기' 카테고리의 다른 글
백준 27866번 자바 - 문자와 문자열 (0) | 2024.05.02 |
---|---|
백준 1546번 자바 - 평균 (0) | 2024.05.02 |
백준 3052번 자바 - 나머지 (0) | 2024.05.01 |
백준 5597번 자바 - 과제 안 내신 분..? (0) | 2024.05.01 |
백준 10813번 자바 - 공 바꾸기 (0) | 2024.04.30 |