아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Room Evacuation

시간 제한7초메모리 제한1024 MB

요약
사람, 벽, 출구가 있는 격자에서 t초 안에 출구에 도달할 수 있는 사람의 최대 수를 구한다. 각 칸에는 매초 한 사람만 있을 수 있다.
난이도

보통10점 중 7점

유형
그래프, 최단 경로, 동적 계획법, 이분 탐색
정답자
아직 제출이 없습니다

문제

You are now the fire marshal. It is not a fun job to have. You have a layout of a room in the building as a 2D grid. There are known locations that people will occupy, there are known locations that people cannot walk into or out of, and there are known locations that are exits. You know that two or more people cannot occupy the same cell of the 2D grid at the same time. You know how quickly everyone needs to evacuate the room in seconds. Asssume that the occupants can only move in one of the four cardinal directions (i.e., North, South, East, or West), and can make one move per second. You can assume that although only one person can stand in the exit at a time, a person in the exit is safe, and of course anyone past the exit is safe.

Given the layout of the room and the desired time to evacuate, determine how many people can get out safely.

입력

The first line of input contains three integers, nn, mm (1≤n,m≤201 \le n,m \le 20) and tt (1≤t≤2001 \le t \le 200), where nn and mm are the height and width of the floor plan, and tt is the time allowed to evacuate.

Each of the next nn lines contains a string of length exactly mm, consisting only of the characters "P", "E", "#", and/or ".", where:

  • "P" is a person
  • "E" is an exit
  • "#" is a blocked area that people cannot enter or pass through
  • "." is an open area that people can enter and pass through

출력

Output a single integer, which is the number of occupants of the room can be safely evacuated in the allotted time.

예제2

  1. 예제 1

    입력
    4 5 3
    .....
    ..P#.
    ..PPE
    ..P.E
    
    예상 출력
    4
    
  2. 예제 2

    입력
    3 3 5
    ...
    P#P
    P#E
    
    예상 출력
    2