Guard Evaders
면접 대비시간 제한1초메모리 제한1024 MB
L, F, R 중 하나를 향하는 경비병들이 있을 때, 각 통과가 해당 틈의 두 경비병 방향을 바꾸는 규칙 아래 p명 모두 무사히 지나갈 수 있는지 판정한다.
문제
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 guards labeled through from left to right, each player chooses to run through the gap between guards and (for some ). A player cannot run to the left of the first guard or to the right of the last. If either guard is facing right or guard is facing left (or both), the player is caught. Otherwise, guard turns to face right and guard turns to face left. No other guards change orientation.
Given how the guards are initially facing and the number of players on your team, can all players run through the guards without getting caught?
입력
The first line of input contains two positive integers: the number of guards and the number of players on your team . 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.