CF2124A.Deranged Deletions

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Deranged Deletions

Call an array bb of length mm a derangement if the following property holds:

  • Let cc be an array of length mm such that ci=bic_i = b_i over all 1im1 \leq i \leq m.
  • Sort cc in non-decreasing order.
  • If bicib_i\neq c_i over all 1im1\leq i \leq m, then bb is a derangement.

For example,

  • If b=[4,8,3,1]b = [4,8,3,1], then c=[1,3,4,8]c = [1, 3, 4, 8] after getting sorted. Since bicib_i \neq c_i in all positions, bb is a derangement.
  • If b=[3,2,1]b = [3,2,1], then c=[1,2,3]c = [1, 2, 3] after getting sorted. Since b2=c2b_2 = c_2, bb is not a derangement.

You are given an array aa of length nn. In one operation, you can delete an element from aa. The order of the remaining elements is preserved after each deletion.

Output whether it is possible to perform some (possibly none) operations such that the remaining elements form a derangement. If it is possible, output any possible remaining array. The remaining array must be non-empty.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1001 \le t \le 100). The description of the test cases follows.

The first line of each test case contains an integer nn (1n1001 \leq n \leq 100) — the length of array aa.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ain1 \leq a_i \leq n) — denoting the array aa.

Output

For each test case, on a new line, if it is possible to perform operations such that the remaining array is a derangement, output YES. Otherwise, output NO.

You can output in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

If your response was positive, output two more lines in the following format:

  • The first line should contain an integer kk (1kn1 \leq k \leq n), the number of elements that remain in the array.
  • The second line should contain d1,d2,dkd_1, d_2 \ldots, d_k, the elements that remain in the array. It must be possible to acquire array dd after performing some operations on aa. Array dd must be a derangement.

Note

In the second test case, we can delete one 55 from the array so that it becomes [4,5,2,4][4,5,2,4]. It can be shown this array is a derangement. This is not the only solution – it can be shown that the original array [4,5,5,2,4][4,5,5,2,4] is another valid solution.

Samples

3
3
2 2 3
5
4 5 5 2 4
1
1
NO
YES
4
4 5 2 4
NO

在线编程 IDE

建议全屏模式获得最佳体验