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

27388번 - MazeMan 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB101715266.667%

문제

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 $n$ and $m$ (3ドル \le n,m \le 100$), where $n$ is the number of rows in the maze representation, and $m$ is the number of columns.

Each of the next $n$ lines contains a string of length exactly $m,ドル consisting only of the capital letters A through X, space, or period. This is the maze. The borders of the maze (rows 1ドル$ and $n,ドル columns 1ドル$ and $m$) 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 0ドル$ if no dots are reachable), and the second of which is the number of dots which cannot be reached.

제한

예제 입력 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

예제 출력 1

2 3

예제 입력 2

3 5
XDRVX
X.X.X
XXXXX

예제 출력 2

2 0

예제 입력 3

3 5
NAQXX
X X.X
XXXXX

예제 출력 3

0 1

힌트

출처

ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2022 E번

  • 문제를 만든 사람: Bob Bradley
(追記) (追記ここまで)

출처

대학교 대회

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

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