QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#17246. Apparently Make UTPC

Estadísticas

길이가 각각 $X$, $Y$, $Z$인 양의 정수로 이루어진 수열 $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 \le Y \le Z$가 성립합니다.

당신은 결과 수열이 $A$와 $B$를 모두 연속 부분 수열로 포함하도록 $C$의 원소들을 재배열하고자 합니다.

이 목표를 달성하는 것이 가능한지 판별하세요. 가능하다면, 재배열 후 사전순으로 가장 작은 수열 $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$번째 테스트 케이스에서 목표를 달성할 수 없다면 $i$번째 줄에 -1을 출력하고, 달성할 수 있다면 사전순으로 가장 작은 재배열된 $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.