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

9858번 - Stampede! 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 128 MB2612956.250%

문제

You have an n×n game board. Some squares contain obstacles, except the left- and right-most columns which are obstacle-free. The left-most column is filled with your n pieces, 1 per row. Your goal is to move all your pieces to the right-most column as quickly as possible. In a given turn, you can move each piece N, S, E, or W one space, or leave that piece in place. A piece cannot move onto a square containing an obstacle, nor may two pieces move to the same square on the same turn. All pieces move simultaneously, so one may move to a location currently occupied by another piece so long as that piece itself moves elsewhere at the same time.

Given n and the obstacles, determine the fewest number of turns needed to get all your pieces to the right-hand side of the board.

입력

Each test case starts with a positive integer n indicating the size of the game board, with n ≤ 25. Following this will be n lines containing n characters each. If the jth character in the ith line is an ‘X’, then there is an obstacle in board location i, j; otherwise this character will be a ‘.’ indicating no obstacle. There will never be an obstacle in the 0th or (n−1)st column and there will always be at least one obstacle-free path between these two columns. A line containing a single 0 will terminate input.

출력

For each test case output the minimum number of turns to move all the pieces from the left side of the board to the right side.

제한

예제 입력 1

5
.....
.X...
...X.
..X..
.....
5
.X...
.X...
.X...
.XXX.
.....
0

예제 출력 1

Case 1: 6
Case 2: 8

힌트

출처

ICPC > Regionals > North America > East Central North America Regional > 2013 East Central Regional Contest E번

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

출처

대학교 대회

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

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