#722
Silver III
Printing Sequences
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie is learning to code using a simple programming language. She first defines a valid program, then executes it to produce some output sequence.

Defining: A program is a nonempty sequence of statements.A statement is either of the form "PRINT cc" where cc is an integer, or "REP oo", followed by a program, followed by "END," where oo is an integer that is at least 1. Executing: Executing a program executes its statements in sequence.Executing the statement "PRINT cc" appends cc to the output sequence.Executing a statement starting with "REP oo" executes the inner program a total of oo times in sequence.

An example of a program that Bessie knows how to write is as follows.

REP 3 PRINT 1 REP 2 PRINT 2 END END

The program outputs the sequence [1,2,2,1,2,2,1,2,2][1,2,2,1,2,2,1,2,2].

Bessie wants to output a sequence of NN (1N1001 \le N \le 100) positive integers. Elsie challenges her to use no more than KK (1K31 \le K \le 3) "PRINT" statements. Note that Bessie can use as many "REP" statements as she wants. Also note that each positive integer in the sequence is no greater than KK.

For each of TT (1T1001 \le T \le 100) independent test cases, determine whether Bessie can write a program that outputs some given sequence using at most KK "PRINT" statements.

입력

The first line contains TT.

The first line of each test case contains two space-separated integers, NN and KK.

The second line of each test case contains a sequence of NN space-separated positive integers, each at most KK, which is the sequence that Bessie wants to produce.

출력

For each test case, output "YES" or "NO" (case sensitive) on a separate line.

예제 입력 1

2
1 1
1
4 1
1 1 1 1

예제 출력 1

YES
YES

예제 입력 2

11
4 2
1 2 2 2
4 2
1 1 2 1
4 2
1 1 2 2
6 2
1 1 2 2 1 1
10 2
1 1 1 2 2 1 1 1 2 2
8 3
3 3 1 2 2 1 2 2
9 3
1 1 2 2 2 3 3 3 3
16 3
2 2 3 2 2 3 1 1 2 2 3 2 2 3 1 1
24 3
1 1 2 2 3 3 3 2 2 3 3 3 1 1 2 2 3 3 3 2 2 3 3 3
9 3
1 2 2 1 3 3 1 2 2
6 3
1 2 1 2 2 3

예제 출력 2

YES
NO
YES
NO
YES
YES
YES
YES
YES
NO
NO

점수

Input 3: K=1K=1Inputs 4-7: K2K \le 2Inputs 8-13: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Silver III1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.