問題一覧 > 通常問題

No.2928 Gridpath

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 99
作問者 : amesyu / テスター : 👑 loop0919 kusirakusira hirayuu_yc mymelochan uruzunyaa tnodino nouka28
お気に入りにしたユーザー ProblemId : 11346 / 自分の提出
問題文最終更新日: 2024-10-12 14:37:36
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
第3回緑以下コンテスト (順位表) の他の問題:

Problem Statement

There is a grid with $H$ rows and $W$ columns. The cell in the $i ~ (1 \le i \le H)$-th row from the top and the $j ~ (1 \le j \le W)$-th column from the left is denoted by cell $(i, j)$. Each cell is either an obstacle cell or an empty cell.

From your current cell, you can move to an empty cell adjacent vertically or horizontally. However, you cannot move outside the grid.

Given $S_i, S_j, G_i, G_j$, solve the following problem.

There are $2^{HW - 2}$ grids obtained by placing obstacles on $0$ or more cells other than cells $(S_i, S_j), (G_i, G_j)$ and making the remaining cells empty.
Among the movement paths from cell $(S_i, S_j)$ to cell $(G_i, G_j)$, find the number of movement paths that are shortest in at least one of the $2^{HW - 2}$ grids.

Constraints

  • $1 \leq H, W \leq 6$
  • $1 \leq S_i, G_i \leq H$
  • $1 \leq S_j, G_j \leq W$
  • $(S_i, S_j) \neq (G_i, G_j)$
  • All input values are integers.

Input

The input is given from standard input in the following format.

$H\ W$
$S_i\ S_j$
$G_i\ G_j$

Output

Output the answer on one line.

Sample

Sample 1
Input
2 3
1 1
1 3
Output
2

The following 2 paths satisfy the condition.

Sample 2
Input
2 6
1 1
1 6
Output
11

The red path is not a shortest path. This is because, on any grid board where the red path exists, the blue path is the shortest path, so the red path can never be a shortest path.

Sample 3
Input
6 6
1 1
1 6
Output
1594

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