Flipping Sequence
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
Special Judge, 64bit IO Format: %lld

题目描述

There is a binary sequence s of length n. You may perform the following operation on this sequence:
  • Choose a non-empty contiguous subsegment of the sequence and flip all elements in that subsegment (change 0 to 1 and 1 to 0).
You need to perform the minimum number of operations so that, in the resulting sequence, the number of 0s and the number of 1s differ by exactly d. Determine whether this is possible, and if it is, output each operation.

输入描述:

The first line contains an integer T (1\le T\le 10^3), the number of test cases.

For each test case, the first line contains two integers n and d (1\le n\le 2\times 10^3,0\le d\le n), as described in the statement.

The second line contains a sequence s of length n consisting only of \t{0} and \t{1}, as described in the statement.

It is guaranteed that \sum n\le 2\times 10^4 over all test cases.

输出描述:

For each test case, if it is impossible to satisfy the requirement, output one line containing \texttt{NO}.

Otherwise, first output YES, then output an integer k, the minimum number of operations. Output one space between \texttt{YES} and k.

Then output k lines in the order the operations are performed. For the i-th operation, output two integers l_i,r_i (1\le l_i\le r_i\le n), indicating that the subsegment [l_i,r_i] is flipped.

If there are multiple operation sequences that make the resulting sequence satisfy the requirement using the minimum number of operations, output any one of them.
示例1

输入

复制
3
4 0
1100
4 1
0111
5 3
00101

输出

复制
YES 0
NO
YES 1
1 2

备注:

For the first sample, no operation is needed to satisfy the condition.

For the second sample, it is impossible to satisfy the condition regardless of the operations performed.

For the third sample, after flipping the subsegment [1,2], the sequence becomes \texttt{11101}, which satisfies the condition.