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

30294번 - Flea 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB376635525.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.

제한

  • $N,ドル $M,ドル and $K$ are integers.
  • 1ドル\le N\le 2,円 000$
  • 1ドル\le M\le 2,円 000$
  • 1ドル\le K\le 2,円 000$
  • Each string consists of U, D, L, or R.

예제 입력 1

5 5 2
DDDRD
DDDDD
RDLUL
UURUU
UUUUU

예제 출력 1

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.

  • A flea at (1, 3) can escape by jumping along the following path: (1, 3) $\rightarrow$ (2, 3) $\rightarrow$ (4, 3) $\rightarrow$ (4, 4) $\rightarrow$ (3, 4) $\rightarrow$ (1, 4) $\rightarrow$ out of the trap
  • A flea at (1, 4) can escape by jumping two glues to the right.

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2023 KAIST 13th ICPC Mock Competition C번

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 2: K-ontest C번

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

출처

대학교 대회

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

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