Cheese Touch

면접 대비

시간 제한2초메모리 제한2048 MB

요약
건강한 사람, 감염자, 벽으로 이루어진 1차원 배열에서 p분마다 감염이 인접 칸으로 퍼질 때, t분에 도착하는 치료제가 모든 건강한 사람이 감염되기 전에 오는지 판정한다.
난이도

쉬움10점 중 3점

유형
시뮬레이션, 구현, 배열, 수학
정답자
아직 제출이 없습니다

문제

Colorado School of Mines has a big problem! Somebody left a piece of cheese in front of the Student Center, and now several students are infected with the "cheese touch". These infected students can spread it to anyone adjacent to them, but not through walls. Although a cure is being developed, it may not come fast enough to stop the spread.

The "cheese touch" spreads every pp minutes (at times p,2p,3p,…p, 2p, 3p, \ldots), infecting people directly adjacent to infected individuals. The cure will be ready after tt minutes. The cure acts immediately, so the infection is not spread at time tt or any time after.

입력

The first line of input contains two integers pp (1≤p≤30001 \leq p \leq 3000) and tt (1≤t≤30001 \leq t \leq 3000) representing the minutes it takes for the "cheese touch" to spread and the minutes it takes to find a cure, respectively.

The second line contains a single string ss (1≤∣s∣≤30001 \leq |s| \leq 3000) consisting of the characters 'H', 'I', and 'W' representing the initial configuration of Healthy people, Infected people, and Walls, respectively. It is guaranteed that there will be at least 11 healthy person.

출력

Print out "CURED" if the cure was released before all the healthy people became infected or "ALL INFECTED" if the cure came too late (without quotes).

예제3

  1. 예제 1

    입력
    1 3
    HIH
    
    예상 출력
    ALL INFECTED
    
  2. 예제 2

    입력
    1 10
    HWIIHI
    
    예상 출력
    CURED
    
  3. 예제 3

    입력
    2 4
    HHIWHI
    
    예상 출력
    CURED