#C4917. Avoid Uniform K-Subarray via Rotation
Avoid Uniform K-Subarray via Rotation
Avoid Uniform K-Subarray via Rotation
Given a sequence of N integers and an integer K, determine if there exists a cyclic rotation of the sequence such that no contiguous subarray of length K in the rotated sequence is composed entirely of identical elements.
Note that if K equals 1, then every rotation trivially satisfies the condition, and the answer is always "Yes". Otherwise, if the original sequence has any contiguous subarray of length K where all elements are the same, then no rotation can avoid having such a subarray, and the answer is "No".
Input is read from standard input and output is written to standard output.
inputFormat
The first line contains two space-separated integers N and K, where N is the length of the sequence and K is the length of the subarray to check.
The second line contains N space-separated integers representing the elements of the sequence.
outputFormat
Output a single line containing either "Yes" if there exists a rotation of the sequence that avoids any contiguous subarray of length K with all identical elements, or "No" otherwise.
## sample5 3
1 2 3 1 2
Yes
</p>