問題一覧 > ネタ問題

No.8063 Breadth-First Search

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 138
作問者 : googol_S0
お気に入りにしたユーザー ProblemId : 4103 / 自分の提出
問題文最終更新日: 2020-03-19 20:09:17
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder April Fool Contest 2020 (順位表) の他の問題:

Problem Statement

Takahashi likes mazes. He is now trying to solve a maze on a two-dimensional board where he can move up, down, left, and right. The board is given in the following format.
・First, the size of the board and the coordinates of the start and goal of the maze are given.
・Next, a board is given with information on whether each cell is an empty cell (.) or a wall cell (#). The start and the goal are always empty cells, and the goal is always reachable from the start.
Output the minimum number of moves required to go from the start to the goal in this maze. Note that you cannot move diagonally.

Input

$R\ C$
$sy\ sx$
$gy\ gx$
$c_{(1,1)}\ c_{(1,2)}\ ...\ c_{(1,C)}$
$c_{(2,1)}\ c_{(2,2)}\ ...\ c_{(2,C)}$
$.$
$.$
$.$
$c_{(R,1)}\ c_{(R,2)}\ ...\ c_{(R,C)}$

$R,C$ are the number of rows and the number of columns, respectively.
$sy,sx$ are the coordinates of the start: $sy$ is the y-coordinate and $sx$ is the x-coordinate.
$gy,gx$ are the coordinates of the goal: $gy$ is the y-coordinate and $gx$ is the x-coordinate.
$c_{(i,j)}$ indicates whether $(i,j)$ is an empty cell or a wall cell: '.' means an empty cell and '#' means a wall cell.
$1\leq R,C \leq10^3$
$1\leq sy,gy \leq R$
$1\leq sx,gx \leq C$

Output

Print a newline at the end.

Sample

Sample 1
Input
4 4
2 2
3 3
####
#..#
#..#
####
Output
2

Sample 2
Input
10 10
2 2
9 9
##########
#........#
#.######.#
#.######.#
#.######.#
#.######.#
#.######.#
#.######.#
#........#
##########
Output
14

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。