Not-So-Long Increasing Subsequence

시간 제한2초메모리 제한256 MB

요약
순열과 길이 K가 주어질 때, 최장 증가 부분 수열의 길이가 (K+1)/2 이하인 길이 K의 부분 수열을 찾거나, 존재하지 않음을 판정한다.
난이도

어려움10점 중 8점

유형
그리디, 구현, 정렬, 조합론
정답자
아직 제출이 없습니다

문제

Let N,KN, K be positive integers satisfying K≤NK \leq N. Busy Beaver has a permutation1 a_1,…,a_Na\_1, \ldots, a\_N of 1,…,N1, \dots, N. A length KK subsequence2 of a_1,…,a_Na\_1, \ldots, a\_N given by b_1,…,b_Kb\_1, \ldots, b\_K is interesting if the longest increasing3 subsequence of b_1,…,b_Kb\_1, \dots, b\_K has length at most K+12\frac{K+1}{2}.

Determine whether Busy Beaver's permutation has an interesting subsequence of length KK, and if it exists, provide such an example of an interesting subsequence.


1A permutation of length NN is an array consisting of NN distinct integers from 11 to NN in arbitrary order. For example, \[2,3,1,5,4]\[2,3,1,5,4] is a permutation, but \[1,2,2]\[1,2,2] is not a permutation (22 appears twice in the array), and \[1,3,4]\[1,3,4] is also not a permutation (N=3N=3 but there is 44 in the array).

2A sequence aa is a subsequence of a sequence bb if aa can be obtained from bb by the deletion of several (possibly, zero or all) elements.

3A sequence a_1,…,a_ma\_1, \dots, a\_m is increasing if a_1<a_2<⋯<a_m−1<a_ma\_1 < a\_2 < \dots < a\_{m-1} < a\_m. For instance, \[1,2,5]\[1, 2, 5] is increasing while \[2,5,1]\[2, 5, 1] is not.

입력

Each test contains multiple test cases. The first line of input contains a single integer TT (1≤T≤105)(1 \leq T \leq 10^5), the number of test cases. The description of each test case follows.

The first line of each test case contains two space-separated integers N,KN, K (1≤K≤N≤2⋅1051 \leq K \leq N \leq 2 \cdot 10^5).

The second line of each test case contains NN integers a_1,a_2,…,a_Na\_1, a\_2, \ldots, a\_N (1≤a_i≤N1 \leq a\_i \leq N, a_ia\_i pairwise distinct) --- Busy Beaver's permutation.

It is guaranteed that the sum of NN across all test cases is no more than 2⋅1052 \cdot 10^5.

출력

For each test case, output "YES" (without quotes) if there exists an interesting subsequence, and "NO" (without quotes) otherwise. You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).

Then, if you responded with "YES", print a second line consisting of KK space-separated integers i_1,…,i_Ki\_1, \dots, i\_K (1≤i_1<⋯<i_K≤n1 \leq i\_1 < \dots < i\_K \leq n), the indices of the permutation such that a_i_1,…,a_i_Ka\_{i\_1}, \dots, a\_{i\_K} is an interesting subsequence. If there are multiple possible solutions, print any of them.

힌트

In the first test case, the subsequence \[a_2,a_3]=\[2,1]\[a\_2, a\_3] = \[2, 1] has two longest increasing subsequences \[2]\[2] and \[1]\[1], each of which has length at most 2+12=32.\frac{2 + 1}{2} = \frac 32. It is therefore an interesting subsequence.

In the second test case, the subsequence \[a_5,a_6,a_7]=\[7,2,6]\[a\_5, a\_6, a\_7] = \[7, 2, 6] has a unique longest increasing subsequence given by \[2,6]\[2, 6], which has length at most 3+12=2.\frac{3 + 1}{2} = 2. It is therefore an interesting subsequence.

In the third test case, the only subsequence of length 88 is the entire sequence \[a_1,…,a_8]=\[4,5,6,7,8,1,2,3]\[a\_1, \dots, a\_8] = \[4, 5, 6, 7, 8, 1, 2, 3]. The longest increasing subsequence of this sequence is \[4,5,6,7,8]\[4, 5, 6, 7, 8]. As its length is greater than 8+12=92\frac{8 + 1}{2} = \frac 92, there is no interesting subsequence.

예제1

  1. 예제 1

    입력
    10
    4 2
    4 2 1 3
    7 3
    3 1 4 5 7 2 6
    8 8
    4 5 6 7 8 1 2 3
    6 4
    5 2 4 3 1 6
    9 8
    1 3 2 4 6 5 7 9 8
    9 7
    1 3 2 4 6 5 7 9 8
    9 5
    1 6 8 9 2 5 3 4 7
    3 2
    3 2 1
    3 2
    1 2 3
    1 1
    1
    
    예상 출력
    YES
    2 3 
    YES
    5 6 7 
    NO
    YES
    1 2 4 5 
    NO
    YES
    2 3 5 6 7 8 9 
    YES
    3 4 6 7 8 
    YES
    2 3 
    NO
    YES
    1