Universal Cup Judging System

Universal Cup

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

Bạn được cho hai dãy $A$ và $B$ có độ dài $N$.

Với mọi $i$ ($1 \le i \le N$), hãy xác định xem có tồn tại một hoán vị $C$ của $(1, 2, \dots, N)$ sao cho LIS (Dãy con tăng dài nhất) của tiền tố độ dài $i$ có độ dài là $A_i$, và LDS (Dãy con giảm dài nhất) của tiền tố độ dài $i$ có độ dài là $B_i$ hay không.

Nếu tồn tại một hoán vị như vậy, hãy xây dựng một hoán vị.

Dữ liệu vào

Dữ liệu vào được cung cấp theo định dạng sau:

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

Ràng buộc

  • $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$)
  • Tất cả các giá trị đầu vào đều là số nguyên.

Dữ liệu ra

Nếu không tồn tại hoán vị như vậy, hãy in ra $-1$. Ngược lại, hãy in ra $N$ số nguyên cách nhau bởi dấu cách biểu diễn các phần tử của hoán vị $C$. Nếu có nhiều hoán vị thỏa mãn, bất kỳ hoán vị nào trong số đó đều được chấp nhận.

Ví dụ

Đầu vào 1

3
1 1 2
1 2 2

Đầu ra 1

2 1 3

Đầu vào 2

4
1 1 2 2
1 2 2 3

Đầu ra 2

3 2 4 1

Đầu vào 3

4
1 2 2 3
1 2 2 2

Đầu ra 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.