QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20961. 바꾸고 또 바꾸기

Statistics

Farmer John의 소 $N$마리($1\le N\le 100$)가 한 줄로 서 있습니다. 각 $1\le i\le N$에 대해 왼쪽에서 $i$번째 소의 번호는 $i$입니다.

Farmer John은 새 아침 운동을 생각해 다음 두 단계를 정확히 $K$번($1\le K\le 10^9$) 반복하라고 합니다.

  1. 현재 왼쪽에서 위치 $A_1 \ldots A_2$에 있는 소들의 순서를 뒤집습니다($1\le A_1<A_2\le N$).

  2. 그다음 현재 왼쪽에서 위치 $B_1 \ldots B_2$에 있는 소들의 순서를 뒤집습니다($1\le B_1<B_2\le N$).

이 과정을 정확히 $K$번 반복한 뒤 각 $1\le i\le N$에 대해 왼쪽에서 $i$번째 소의 번호를 출력하세요.

입력

첫 줄에는 $N$과 $K$, 둘째 줄에는 $A_1$와 $A_2$, 셋째 줄에는 $B_1$와 $B_2$가 주어집니다.

출력

출력의 $i$번째 줄에는 운동이 끝난 뒤 왼쪽에서 $i$번째 소의 번호를 출력하세요.

예제

입력 1

7 2
2 5
3 7

출력 1

1
2
4
3
5
7
6

참고

처음 왼쪽부터 순서는 $[1,2,3,4,5,6,7]$입니다. 첫 단계 뒤에는 $[1,5,4,3,2,6,7].$ 둘째 단계 뒤에는 $[1,5,7,6,2,3,4]$입니다. 두 단계를 한 번 더 반복하면 예제 출력이 됩니다.

서브태스크

  • 테스트 2–3은 $K\le 100$을 만족합니다.
  • 테스트 4–13에는 추가 제한이 없습니다.

문제 출제자: Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.