시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
3 초 | 1024 MB | 9 | 6 | 6 | 100.000% |
Playing games is fun. For programmers, however, playing games with programs is even more fun. Consider a simple single-user tabletop game as follows. Given a row of sticks, each of which is in one of the seven colors, red (R), green (G), blue (B), cyan (C), magenta (M), yellow (Y), and key (K), the goal of the game is to eliminate all the sticks by repeating the following rules.
For the case where the row is BBBRRRRRRGGGB
and m is 3, all the sticks can be successfully eliminated as the following steps:
BBBRRRRRRGGGB
BBBGGGB
(By eliminating all red sticks)BBBB
(By eliminating all green sticks)For the same row of sticks with m = 4, however, it is no way to eliminate all the sticks.
Given a row of n sticks and the value of m, your task is to determine if it is possible to eliminate all the sticks.
Each test case is given as a string that is the row of sticks and an integer m.
Output Yes
if it is possible to eliminate all the sticks. Otherwise, output No
.
BBBRRRRRRGGGB 3
Yes
BBBRRRRRRGGGB 4
No