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.