| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 1024 MB | 376 | 63 | 55 | 25.581% |
You have placed glues on each cells of an $N\times M$ 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 $K$ 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 $N,ドル $M$ and the jump limit $K$ are given, separated by spaces.
For the next $N$ lines, each line contains a string of length $M,ドル indicating the weak direction of each cell.
Print the number of escapable cells.
U, D, L, or R.5 5 2 DDDRD DDDDD RDLUL UURUU UUUUU
14
Fleas which start from (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 3), (4, 4), (4, 5), (5, 3), (5, 4), and (5, 5) can escape.