QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#17246. Apparently Make UTPC

统计

تُعطى لك متتاليات من الأعداد الصحيحة الموجبة $A = (A_1, A_2, \dots, A_X)$ و $B = (B_1, B_2, \dots, B_Y)$ و $C = (C_1, C_2, \dots, C_Z)$ بأطوال $X$ و $Y$ و $Z$ على التوالي. هنا، يتحقق الشرط $X \le Y \le Z$.

تريد إعادة ترتيب عناصر $C$ بحيث تحتوي المتتالية الناتجة على كل من $A$ و $B$ كمتتاليتين فرعيتين متجاورتين (contiguous subsequences).

حدد ما إذا كان من الممكن تحقيق هذا الهدف. إذا كان ذلك ممكناً، فأوجد المتتالية $C$ الأصغر معجمياً بعد إعادة الترتيب.

تُعطى لك $T$ من حالات الاختبار. حل كلاً منها.

الإدخال

يُعطى الإدخال من الإدخال القياسي بالصيغة التالية:

$$\begin{aligned} &T \\ &\text{case}_1 \\ &\text{case}_2 \\ &\vdots \\ &\text{case}_T \end{aligned}$$

تُعطى كل حالة بالصيغة التالية:

$$\begin{aligned} &X \ Y \ Z \\ &A_1 \ A_2 \ \dots \ A_X \\ &B_1 \ B_2 \ \dots \ B_Y \\ &C_1 \ C_2 \ \dots \ C_Z \end{aligned}$$

  • جميع قيم الإدخال هي أعداد صحيحة.
  • $1 \le T \le 10^5$
  • $1 \le X \le Y \le Z \le 2 \times 10^5$
  • $1 \le A_i \le Z$
  • $1 \le B_i \le Z$
  • $1 \le C_i \le Z$
  • مجموع $X + Y + Z$ عبر جميع حالات الاختبار في إدخال واحد هو على الأكثر $4 \times 10^5$.

الإخراج

اطبع $T$ أسطر. يجب أن يحتوي السطر الـ $i$ على -1 إذا كان لا يمكن تحقيق الهدف لحالة الاختبار الـ $i$، أو المتتالية $C$ المعاد ترتيبها الأصغر معجمياً إذا كان بالإمكان تحقيقه.

أمثلة

إدخال 1

3
2 2 4
4 3
2 1
4 3 2 1
2 3 4
4 3
3 2 1
4 3 2 1
3 3 3
1 1 1
2 2 2
3 3 3

إخراج 1

2 1 4 3
4 3 2 1
-1

ملاحظة

  • في المثال الأول، المتتاليات الممكنة بعد إعادة ترتيب $C$ هي $(2, 1, 4, 3)$ و $(4, 3, 2, 1)$. اطبع $(2, 1, 4, 3)$، وهي الأصغر معجمياً.
  • في المثال الثاني، المتتالية الوحيدة الممكنة بعد إعادة ترتيب $C$ هي $(4, 3, 2, 1)$. اطبع $(4, 3, 2, 1)$.
  • في المثال الثالث، لا يمكن تحقيق الهدف. اطبع -1.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#2918EditorialOpenHashc20262110View
#1405EditorialOpen题解jianglyView

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.