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

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

MazeMan

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

요약
문자가 입구이고 점이 먹을 대상인 미로에서 도달 가능한 모든 점을 먹는 데 필요한 최소 입구 수와 도달할 수 없는 점의 개수를 구한다.
난이도

보통10점 중 6점

유형
그래프, BFS, 그리디
정답자
아직 제출이 없습니다

문제

You now work for a video game company - every programmer's dream! You are working on a multiplayer game where players cooperate to enter a maze and try to consume all of the "dots" as quickly as possible. Each player enters the maze at a different entrance. The mazes are randomly generated, so the minimum number of players needed to consume all of the dots can vary, and some dots may not be reachable at all.

You are working in the Quality Control department, analyzing the randomly generated mazes. For analysis, the mazes are represented in text. An X is a wall that cannot be crossed. Letters A-W are entrances. Players can only move up, down, left and right. Players can move though spaces and dots; moving over a dot eats it. If two doors are adjacent, players cannot move from one to the other. For example:

XXXXXXXAXXXXXXXBXXXX
X.. ..X.X...... ...X
X.XXX...X.X.XXXXXX.X
X.X.XXXXX.X.X....X.X
X.X... ...X.X.XX.X.X
X.X.X.XXXXXXX.XX.X.X
X.X.X.X...X...X....X
X.X.X.XXXXXXX.XXXX.X
X...X.X X.. ..X..X.X
XXXXXXXDXXXXXXXXCXXX

All of the reachable dots can be reached from entrances A and C (or, equivalently, B and C). There are three dots that cannot be reached.

Calculate the minimum number of players necessary to eat all the reachable dots, and how many dots are not reachable because they are walled off.

입력

This first line of input contains two integers nn and mm (3≤n,m≤1003 \le n,m \le 100), where nn is the number of rows in the maze representation, and mm is the number of columns.

Each of the next nn lines contains a string of length exactly mm, consisting only of the capital letters A through X, space, or period. This is the maze. The borders of the maze (rows 11 and nn, columns 11 and mm) are guaranteed to consist only of capital letters A through X. There are no entrances (A-W) in the middle of the maze.

출력

Output a line with two space-separated integers, the first of which is the minimum number of entrances necessary to enter in order to eat all of the dots (which may be 00 if no dots are reachable), and the second of which is the number of dots which cannot be reached.

예제3

  1. 예제 1

    입력
    10 20
    XXXXXXXAXXXXXXXBXXXX
    X.. ..X.X...... ...X
    X.XXX...X.X.XXXXXX.X
    X.X.XXXXX.X.X....X.X
    X.X... ...X.X.XX.X.X
    X.X.X.XXXXXXX.XX.X.X
    X.X.X.X...X...X....X
    X.X.X.XXXXXXX.XXXX.X
    X...X.X X.. ..X..X.X
    XXXXXXXDXXXXXXXXCXXX
    
    예상 출력
    2 3
    
  2. 예제 2

    입력
    3 5
    XDRVX
    X.X.X
    XXXXX
    
    예상 출력
    2 0
    
  3. 예제 3

    입력
    3 5
    NAQXX
    X X.X
    XXXXX
    
    예상 출력
    0 1