QOJ.ac

QOJ

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

#20961. Đổi rồi lại đổi

Statistics

$N$ con bò của Farmer John ($1\le N\le 100$) đứng thành hàng. Với mỗi $1\le i\le N$, con thứ $i$ từ trái có nhãn $i$.

Farmer John nghĩ ra bài tập sáng mới và yêu cầu lặp đúng $K$ ($1\le K\le 10^9$) lần hai bước sau:

  1. Các bò hiện ở vị trí $A_1 \ldots A_2$ tính từ trái đảo ngược thứ tự ($1\le A_1<A_2\le N$).

  2. Sau đó các bò hiện ở vị trí $B_1 \ldots B_2$ tính từ trái đảo ngược thứ tự ($1\le B_1<B_2\le N$).

Sau đúng $K$ lần lặp, với mỗi $1\le i\le N$ hãy xuất nhãn bò thứ $i$ từ trái.

Dữ liệu vào

Dòng đầu chứa $N$ và $K$, dòng hai $A_1$ và $A_2$, dòng ba $B_1$ và $B_2$.

Dữ liệu ra

Ở dòng kết quả thứ $i$, xuất nhãn bò thứ $i$ từ trái khi tập xong.

Ví dụ

Dữ liệu vào 1

7 2
2 5
3 7

Dữ liệu ra 1

1
2
4
3
5
7
6

Ghi chú

Ban đầu thứ tự trái sang phải là $[1,2,3,4,5,6,7]$. Sau bước đầu là $[1,5,4,3,2,6,7].$ Sau bước hai là $[1,5,7,6,2,3,4]$. Lặp cả hai bước lần nữa cho kết quả ví dụ.

Nhiệm vụ con

  • Các test 2–3 thỏa mãn $K\le 100$.
  • Các test 4–13 không có giới hạn bổ sung.

Tác giả bài toán: 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.