7486: Alice and Bob

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Alice and Bob decide to play a game. Denote set S={i|i∈[1,n]}. Starting with Alice, take a number from S in turn and put it at the end of a sequence A with deleting it from S. Initially the sequence A is empty. P(A) indicates that A contains an increasing subsequence of length k at this time.

There are two versions of the game:


Version 1: Whoever makes the condition P(A) satisfied for the first time wins.


Version 2: Whoever makes the condition P(A) satisfied for the first time loses.


For the above two versions: whoever can't take out a number fails, i.e., S is empty when it is his turn.

In fact, they have already taken q numbers totally from the set S and none of them have won.

Now please tell Alice if she can win. If she can, tell her how many ways she can take in the next step.

You can assume that Alice and Bob are smart enough since the q+1-th operation.

输入格式

The first line of the input contains a single integer T (1≤T≤1000), the number of test cases.

Each test case includes two lines:

The first line contains 4 integers n, v, q, k ( 3≤n≤105 , 1≤v≤2, 2≤q<n, \textbf{q is even} , 2≤k≤105 ), denoting the size of S, the version of the game, the number of the numbers already taken, the parameter denoting the length of increasing subsequence.

The second line contains q integers denoting numbers taken out alreadly in order by steps.
It is guaranteed that ∑n,∑q∈[1,106].

输出格式

For each test case:


If Alice can't win, print a single line containing "NO".


Otherwise, print a single line containing "YES" and an integer which denotes the number of different operations Alice can take in the next step to win with only one space seperated.

输入样例 复制

2
3 1 2 3
3 2
4 2 2 3
4 3
 

输出样例 复制

YES 1
NO