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.