QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#17246. Apparently Make UTPC

Statistiques

Þér eru gefnar runur jákvæðra heiltalna $A = (A_1, A_2, \dots, A_X)$, $B = (B_1, B_2, \dots, B_Y)$ og $C = (C_1, C_2, \dots, C_Z)$ af lengdum $X$, $Y$ og $Z$, í þessari röð. Hér gildir $X \le Y \le Z$.

Þú vilt endurraða stökum $C$ þannig að runan sem fæst innihaldi bæði $A$ og $B$ sem samfelldar hlutrunur.

Ákvarðaðu hvort hægt sé að ná þessu markmiði. Ef það er hægt, finndu þá runu $C$ sem er minnst í stafrófsröð (lexicographically smallest) eftir endurröðunina.

Þér eru gefin $T$ prófunartilfelli. Leystu hvert þeirra.

Inntak

Inntakið er gefið úr staðalinntaki á eftirfarandi sniði:

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

Hvert tilfelli er gefið á eftirfarandi sniði:

$$\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}$$

  • Öll inntaksgildi eru heiltölur.
  • $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$
  • Summa $X + Y + Z$ yfir öll prófunartilfelli í einu inntaki er í mesta lagi $4 \times 10^5$.

Úttak

Prentaðu $T$ línur. Lína $i$ á að innihalda -1 ef ekki er hægt að ná markmiðinu fyrir $i$-ta prófunartilfellið, eða endurraðaða runu $C$ sem er minnst í stafrófsröð ef hægt er að ná því.

Dæmi

Inntak 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

Úttak 1

2 1 4 3
4 3 2 1
-1

Athugasemd

  • Í fyrsta dæminu eru mögulegar endurraðaðar runur fyrir $C$ jafnar $(2, 1, 4, 3)$ og $(4, 3, 2, 1)$. Prentaðu $(2, 1, 4, 3)$, sem er minnst í stafrófsröð.
  • Í öðru dæminu er eina mögulega endurraðaða runan fyrir $C$ jöfn $(4, 3, 2, 1)$. Prentaðu $(4, 3, 2, 1)$.
  • Í þriðja dæminu er ekki hægt að ná markmiðinu. Prentaðu -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.