Universal Cup Judging System

Universal Cup

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

Gegeben sind zwei Folgen $A$ und $B$ der Länge $N$.

Bestimme, ob eine Permutation $C$ von $(1, 2, \dots, N)$ existiert, sodass für alle $i$ ($1 \le i \le N$) die LIS (längste aufsteigende Teilfolge) des Präfixes der Länge $i$ die Länge $A_i$ hat und die LDS (längste absteigende Teilfolge) des Präfixes der Länge $i$ die Länge $B_i$ hat.

Falls eine solche Permutation existiert, konstruiere eine.

Eingabe

Die Eingabe erfolgt im folgenden Format:

$$N$$ $$A_1\ A_2\ \dots\ A_N$$ $$B_1\ B_2\ \dots\ B_N$$

Bedingungen

  • $1 \le N \le 5 \times 10^5$
  • $1 \le A_i \le N$ ($1 \le i \le N$)
  • $1 \le B_i \le N$ ($1 \le i \le N$)
  • Alle Eingabewerte sind ganze Zahlen.

Ausgabe

Falls keine solche Permutation existiert, gib $-1$ aus. Gib andernfalls $N$ durch Leerzeichen getrennte ganze Zahlen aus, welche die Elemente der Permutation $C$ darstellen. Falls es mehrere solche Permutationen gibt, wird jede davon akzeptiert.

Beispiele

Eingabe 1

3
1 1 2
1 2 2

Ausgabe 1

2 1 3

Eingabe 2

4
1 1 2 2
1 2 2 3

Ausgabe 2

3 2 4 1

Eingabe 3

4
1 2 2 3
1 2 2 2

Ausgabe 3

-1

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#2544EditorialOpen题解KobicGendView
#1488EditorialOpen题解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.