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

32670번 - Guard Evaders 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB129975.000%

문제

Here is a new game to play. You and a team of your friends sequentially run through a row of guards (a bit like in the playground game "Rover, Red Rover.") The guards may be facing forward, left, or right. When facing forward, they can't see you coming until it's too late, because they have very limited peripheral vision. (Perhaps they wear blinders.) They can similarly not see you if they are facing sideways away from you as you come through. However, as soon as you pass between a pair of guards, they do hear you and turn to face where you came through, so that if you tried to pass through the same pair of guards again they would be positioned to stop you. Two guards stop a player trying to pass between them if at least one of them is facing the gap that the player attempts to run through.

More formally: Given a row of $g$ guards labeled 1ドル$ through $g$ from left to right, each player chooses to run through the gap between guards $i$ and $i+1$ (for some 1ドル \leq i \leq g-1$). A player cannot run to the left of the first guard or to the right of the last. If either guard $i$ is facing right or guard $i+1$ is facing left (or both), the player is caught. Otherwise, guard $i$ turns to face right and guard $i+1$ turns to face left. No other guards change orientation.

Given how the guards are initially facing and the number of players $p$ on your team, can all $p$ players run through the guards without getting caught?

입력

The first line of input contains two positive integers: the number of guards $g$ $(2 \leq g \leq 10)$ and the number of players on your team $p$ $(1\leq p \leq 50)$. The second line contains a string of uppercase letters representing the directions each of the guards is initially facing. Each character in the string is either L (left), F (forward), or R (right). The first illustration shows four guards configured according to input string RFRL.

출력

If with optimal play all players can make it past the guards without getting caught, print 1. Otherwise print 0.

제한

예제 입력 1

4 1
RFRL

예제 출력 1

1

예제 입력 2

4 2
RFRL

예제 출력 2

0

예제 입력 3

4 4
FFFF

예제 출력 3

1

힌트

출처

ICPC > Regionals > North America > North Central North America Regional > 2024 North Central NA Regional Contest F번

ICPC > Regionals > North America > Mid-Central Regional > 2024 Mid-Central USA Programming Contest H번

  • 문제를 만든 사람: Chuck Riedesel, Josh Brown-Kramer
(追記) (追記ここまで)

출처

대학교 대회

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

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