QOJ.ac

QOJ

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

#20961. Scambio dopo scambio

Statistics

Le $N$ mucche di Farmer John ($1\le N\le 100$) sono in fila. Per ogni $1\le i\le N$, la mucca $i$ da sinistra ha etichetta $i$.

Farmer John ha ideato un nuovo esercizio mattutino e chiede di ripetere esattamente $K$ ($1\le K\le 10^9$) volte questi due passi:

  1. Le mucche attualmente nelle posizioni $A_1 \ldots A_2$ da sinistra invertono il loro ordine ($1\le A_1<A_2\le N$).

  2. Poi le mucche attualmente nelle posizioni $B_1 \ldots B_2$ da sinistra invertono il loro ordine ($1\le B_1<B_2\le N$).

Dopo esattamente $K$ ripetizioni, stampa per ogni $1\le i\le N$ l'etichetta della mucca $i$ da sinistra.

Input

La prima riga contiene $N$ e $K$, la seconda $A_1$ e $A_2$ e la terza $B_1$ e $B_2$.

Output

Nella riga $i$ stampa l'etichetta della mucca $i$ da sinistra alla fine dell'esercizio.

Esempi

Input 1

7 2
2 5
3 7

Output 1

1
2
4
3
5
7
6

Note

Inizialmente l'ordine da sinistra a destra è $[1,2,3,4,5,6,7]$. Dopo il primo passo è $[1,5,4,3,2,6,7].$ Dopo il secondo è $[1,5,7,6,2,3,4]$. Ripetere entrambi una seconda volta dà l'output dell'esempio.

Sottoproblemi

  • I test 2–3 soddisfano $K\le 100$.
  • I test 4–13 non hanno vincoli aggiuntivi.

Autore del problema: 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.