問題一覧 > 通常問題

No.1759 Silver Tour

レベル : / AI推定難易度 : 2600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 16
作問者 : NyaanNyaan / テスター : tokusakurai PCTprobability
お気に入りにしたユーザー ProblemId : 7323 / 自分の提出
問題文最終更新日: 2021-11-20 14:00:55
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 contest 324 (順位表) の他の問題:

Problem Statement

There is a shogi board with $H \times W$ rows and columns and $1$ silver general piece.

As shown in Figure $1$, a silver general can move to the $3$ squares in front of it and to the squares diagonally behind it. However, the destination must be inside the board.

More precisely, denoting the square in the $i$-th row from the top and the $j$-th column from the left by $(i,j)$, a silver placed on $(i,j)$ can move to $(i-1,j-1),(i-1,j),(i-1,j+1),(i+1,j-1),(i+1,j+1)$.

Moving the silver general so that the following condition is satisfied is called a "silver full-board tour".

  • Place the silver on one of the squares in the bottom row of the board, that is, one of $(H,j)$ $(1 \leq j \leq W)$, and move the silver so that it passes through all squares without passing through the same square more than once.

For example, the moves shown in Figure $2$ are one example of a silver full-board tour when $H = W = 2$.

Find the number of possible silver full-board tours, modulo $M$.
Here, two silver full-board tours are considered different if they differ when the moves are viewed as sequences of squares.

Constraints

  • All inputs are integers.
  • $1 \leq H \leq 50$
  • $1 \leq W \leq 50$
  • $9 \times 10^8 \leq M \leq 10^9$

Input

$H\ W\ M$

Output

Output the answer in $1$ line.

Sample

Sample 1
Input
2 2 998244353
Output
2

The silver full-board tours satisfying the condition are the one shown in Figure $2$ and its left-right mirror image, for a total of $2$.

Sample 2
Input
9 9 998244353
Output
0

On a $9 \times 9$ shogi board, a silver full-board tour is impossible, so no moves satisfying the condition exist.

Sample 3
Input
6 5 924844033
Output
60

Sample 3
Input
50 50 1000000000
Output
999575486

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