#P16962. [SCCPC 2026] 交换余生
[SCCPC 2026] 交换余生
Problem Description
Given a sequence of length , determine whether there exists a sequence such that:
- , where and denote the multisets formed by all elements in sequences and , respectively.
- There does not exist any such that .
Input Format
This problem contains multiple test cases.
The first line of the input contains a positive integer (), indicating the number of test cases.
For each test case:
The first line contains a positive integer (), indicating the length of sequence .
The second line contains positive integers (), representing the sequence .
It is guaranteed that .
Output Format
For each test case:
If there exists a sequence satisfying the conditions, output one line "YES"; otherwise, output one line "NO".
You may output the answer in any letter case. For example, "yEs", "yes", "Yes", and "YES" will all be accepted as correct.
7
4
6 12 24 15
5
2 4 3 9 6
6
2 3 5 4 9 25
4
7 7 14 21
2
10 20
3
6 6 6
5
14 21 22 33 17
YES
YES
NO
NO
YES
NO
YES
Hint
Translated by ChatGPT 5