Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

أُعطيت متتاليتين $A$ و $B$ بطول $N$.

حدد ما إذا كان يوجد تبديل $C$ للأعداد $(1, 2, \dots, N)$ بحيث إنه لكل $i$ ($1 \le i \le N$)، يكون طول LIS (أطول متتالية فرعية متزايدة) للبادئة التي طولها $i$ مساويًا لـ $A_i$، وطول LDS (أطول متتالية فرعية متناقصة) للبادئة التي طولها $i$ مساويًا لـ $B_i$.

إذا وجد مثل هذا التبديل، فقم ببناء واحد.

الإدخال

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

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

القيود

  • $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$)
  • جميع قيم الإدخال هي أعداد صحيحة.

الإخراج

إذا لم يوجد مثل هذا التبديل، فاطبع $-1$. وإلا، فاطبع $N$ من الأعداد الصحيحة المفصولة بمسافات تمثل عناصر التبديل $C$. إذا وجدت عدة تبديلات من هذا القبيل، فسيتم قبول أي منها.

أمثلة

الإدخال 1

3
1 1 2
1 2 2

الإخراج 1

2 1 3

الإدخال 2

4
1 1 2 2
1 2 2 3

الإخراج 2

3 2 4 1

الإدخال 3

4
1 2 2 3
1 2 2 2

الإخراج 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.