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

17184번 - Nautilus 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB163645054.945%

문제

Nautilus is a secret submarine, sailing around the ocean and trying to remain hidden.

The ocean is modelled as R × C grid of cells, where “#” represents islands and “.” represents water. For example:

...##....
..#.##..#
..#....##
.##...#..
....#....

Every minute, Nautilus emits a radio signal that can reveal the direction the submarine is about to take. The direction is always one of the following: North (N), East (E), South (S), West (W), as shown on the figure above right.

Vytautas has constructed a radar that intercepts the periodic submarine signals. Over the last M minutes, the radar has collected M radio signals, represented as a sequence of M characters, for example “WS?EE??”. Some of the signals could not be decoded, these are marked as “?”.

Vytautas does not know the initial submarine location, but wants to use the ocean map in order to identify its current location. Given that Nautilus always stays in water cells on the map, help Vytautas calculate the number of distinct cells where Nautilus may be located at currently.

입력

The first line of the input contains three integers R, C, M.

The next R lines form an R × C grid of characters “#” and “.” representing the ocean map.

The last line of the input describes the signals intercepted by Vytautas — a string of M characters, all belonging to the set {N, E, S, W, ?}.

출력

Output a single integer: the number of possible distinct current positions of Nautilus.

제한

서브태스크

번호배점제한
129

1 ≤ R, C, M ≤ 100; there are no “?” symbols.

237

1 ≤ R, C, M ≤ 100.

334

1 ≤ R, C ≤ 500; 1 ≤ M ≤ 5 000.

예제 입력 1

5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??

예제 출력 1

22

힌트

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2019 B번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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