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

17999번 - Maze Connect 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 (추가 시간 없음) 512 MB66474275.000%

문제

Given an orthogonal maze rotated 45 degrees and drawn with ASCII forward and backward slash characters (see below), determine the minimum number of walls that need to be removed to ensure it is possible to escape out of the (possibly disconnected) maze from every cell without going through a wall.

/\
\/

The above maze has only a single cell fully enclosed. Removing any wall will provide an escape route to the outside.

/\..
\.\.
.\/\
..\/

The above maze has two enclosed areas. Two walls need to be removed to connect all cells to the outside.

/\/\/\/\/\/\/\/\/\/\
\../\.\/./././\/\/\/
/./\.././\/\.\/\/\/\
\/\/\.\/\/./\/..\../
/\/./\/\/./..\/\/..\
\.\.././\.\/\/./\.\/
/.../\../..\/./.../\
\/\/\/\/\/\/\/\/\/\/

To make every cell in the above maze accessible from the outside, 26 walls need to be removed.

입력

The first line of input contains two numbers, r and c (1 ≤ r, c ≤ 1000), which are the number of rows (r) and columns (c) in the maze.

Each of the next r lines contains a string with exactly c characters, consisting of ‘.’, ‘/’, or ‘\’ only. Define an odd (even) square in the grid of characters as one where the sum of the x and y coordinates is odd (even). Either all forward slashes will be in the odd squares and all backwards slashes in the even squares, or vice versa.

출력

Output a single integer, which is the least number of walls that need to be removed so that escape is possible from every cell in the maze.

제한

예제 입력 1

2 2
/\
\/

예제 출력 1

1

예제 입력 2

4 4
/\..
\.\.
.\/\
..\/

예제 출력 2

2

예제 입력 3

2 2
\/
/\

예제 출력 3

0

예제 입력 4

8 20
/\/\/\/\/\/\/\/\/\/\
\../\.\/./././\/\/\/
/./\.././\/\.\/\/\/\
\/\/\.\/\/./\/..\../
/\/./\/\/./..\/\/..\
\.\.././\.\/\/./\.\/
/.../\../..\/./.../\
\/\/\/\/\/\/\/\/\/\/

예제 출력 4

26

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2019 Southeast USA Regional Programming Contest > Division 1 I번

ICPC > Regionals > North America > Pacific Northwest Regional > 2019 ICPC Pacific Northwest Region > Division 1 M번

ICPC > Regionals > North America > Pacific Northwest Regional > 2019 ICPC Pacific Northwest Region > Division 2 Z번

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

출처

대학교 대회

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

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