QOJ.ac

QOJ

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

#20961. החלפה ועוד החלפה

Statistics

$N$ הפרות של Farmer John ($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

Note

בתחילה הסדר משמאל לימין הוא $[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.