Universal Cup Judging System

Universal Cup

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

נתונות לכם שתי תמורות $p$ ו-$q$ באורך $n$. אתם יכולים לבצע את הפעולה הבאה על התמורה הראשונה אפס פעמים או יותר:

בחרו $1 \le i < j \le n$ כך ש-$p_i < p_j$ והחליפו בין $p_i$ ל-$p_j$.

עליכם לקבוע האם ניתן להפוך את $p$ לשווה ל-$q$. אם הדבר אפשרי, עליכם למצוא סדרת פעולות מתאימה כלשהי.

קלט

כל בדיקה מכילה מספר מקרי בדיקה. השורה הראשונה מכילה את מספר מקרי הבדיקה $t$ ($1 \le t \le 100$). אחריה מופיע תיאור מקרי הבדיקה.

השורה הראשונה של כל מקרה בדיקה מכילה מספר שלם $n$ ($1 \le n \le 2000$).

השורה השנייה מכילה $n$ מספרים שלמים שונים $p_1, p_2, \dots, p_n$ ($1 \le p_i \le n$).

השורה השלישית מכילה $n$ מספרים שלמים שונים $q_1, q_2, \dots, q_n$ ($1 \le q_i \le n$).

$p$ ו-$q$ הנתונות הן שתיהן תמורות של $\{1, 2, \dots, n\}$.

סכום ערכי ה-$n$ על פני כל מקרי הבדיקה אינו עולה על $2000$.

פלט

עבור כל מקרה בדיקה, קבעו האם קיימת דרך להפוך את $p$ לשווה ל-$q$.

אם כן, הדפיסו YES בשורה הראשונה. בשורה הבאה, הדפיסו מספר שלם $k$, מספר הפעולות שברצונכם לבצע. בשורות הבאות, עליכם להדפיס את הפעולות.

כדי לתאר פעולה המחליפה בין $p_i$ ל-$p_j$ ($1 \le i < j \le n$), הדפיסו שורה בפורמט "$i\ j$".

אחרת, הדפיסו NO בשורה בודדת.

במקרה שישנן מספר תשובות מתאימות, הדפיסו אחת מהן.

דוגמאות

קלט 1

6
2
1 2
2 1
3
1 2 3
3 2 1
5
3 5 1 2 4
4 5 1 3 2
6
2 3 6 4 1 5
3 4 5 6 2 1
6
2 3 6 4 1 5
5 3 6 4 2 1
1
1
1

פלט 1

YES
1
1 2
YES
3
1 2
1 3
2 3
YES
2
1 5
4 5
NO
YES
6
1 2
1 4
1 6
2 4
4 6
5 6
YES
0

הערה

במקרה הבדיקה השני, $p$ היא 1 2 3. אחת מסדרות ההחלפות האפשריות היא: 1 2, 1 3, 2 3.

לאחר ההחלפה הראשונה, $p$ הופכת ל-2 1 3; לאחר ההחלפה השנייה, היא הופכת ל-3 1 2; ולאחר השלישית, ל-3 2 1.

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.