Flea
시간 제한2초메모리 제한1024 MB
각 칸의 화살표 방향으로 최대 K칸씩 점프해 사각형 밖으로 나갈 수 있는 시작 칸의 수를 센다.
문제
You have placed glues on each cells of an grid to create a rectangular flea trap. Each glue has a weak direction; if a flea on the glue jumps towards its weak direction, the flea can jump out of the glue.
More precisely, each glue is represented by U, D, L, or R, meaning up, down, left, and right respectively.
Fleas can jump at most cells in one jump. If a flea jumps out of the rectangle, we say that the flea has escaped.
You became curious about how effective your trap is. If a flea that is placed on a cell of the trap can escape after consecutive jumps, we call the cell an escapable cell. Your task is to count the number of escapable cells.
입력
In the first line, the trap sizes , and the jump limit are given, separated by spaces.
For the next lines, each line contains a string of length , indicating the weak direction of each cell.
출력
Print the number of escapable cells.
제한
- , , and are integers.
- Each string consists of
U,D,L, orR.