Logo
(追記) (追記ここまで)

20260번 - A Color Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB23121285.714%

문제

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.

  • Consecutive sticks with the same color can be eliminated if the size of them is not less than m.
  • The remaining sticks will move closer together.

For the case where the row is BBBRRRRRRGGGB and m is 3, all the sticks can be successfully eliminated as the following steps:

  1. BBBRRRRRRGGGB
  2. BBBGGGB (By eliminating all red sticks)
  3. BBBB (By eliminating all green sticks)
  4. (By eliminating all blue 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.

제한

  • 0 < n, m ≤ 500

예제 입력 1

BBBRRRRRRGGGB 3

예제 출력 1

Yes

예제 입력 2

BBBRRRRRRGGGB 4

예제 출력 2

No

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > 2020 ICPC Asia Taipei-Hsinchu Regional E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /