#P11446. 「ALFR Round 3」B Swap & Delete
「ALFR Round 3」B Swap & Delete
Description
Given a sequence of length , denoted as , you need to perform operations to make this sequence empty.
Each operation can be one of the following:
- Select two indices and swap and , satisfying .
- Select two indices and delete the elements , satisfying , and .
You should output the minimum number of operations required.
Input Format
The first line contains a positive integer (), indicating the number of test cases.
For each test case:
The first line contains a positive integer (), representing the length of the sequence.
The second line contains positive integers ().
Output Format
For each test case, output a single integer , indicating the minimum number of operations.
2
5
1 2 3 2 3
3
1000000000 1000000000 99999999
2
2
Hint
| Subtask | Score | Constraints |
|---|---|---|
| All are guaranteed to be equal | ||
| - |
For all the tests, , , .
京公网安备 11011102002149号