#K73972. Taco Tile Challenge
Taco Tile Challenge
Taco Tile Challenge
You are given a sequence consisting of tiles, each represented by a character: 'B' for black and 'W' for white. Your task is to determine if there exists a contiguous subsequence of exactly k tiles such that every adjacent pair of tiles in this subsequence are of different colors.
Formally, given a tile sequence S of length n and a positive integer k, find an index i (1 ≤ i ≤ n-k+1) such that for every index j (i ≤ j < i+k-1), the following condition holds:
\( S[j] \neq S[j+1] \)
If k = 1, the answer is always "yes" since a single tile trivially satisfies the condition.
inputFormat
The input is given in two lines:
- The first line contains two integers
n
andk
separated by space, where n is the number of tiles. - The second line contains a string of length
n
representing the tile sequence. Each character is either 'B' or 'W'.
outputFormat
Output a single line containing either "yes" if there exists a contiguous subsequence of exactly k
alternating tiles, or "no" otherwise.
6 4
BWBWBW
yes