AtCoder Beginner Contest 265
Ex
No-capture Lance Game
AtCoder
⌀ 3319
原题
←G →
翻译中…

Problem Statement

翻译中…

There is a grid with $H$ horizontal rows and $W$ vertical columns, and $(2 \times H)$ pieces. We consider the following game using them. Two players take alternating turns. The game progresses as follows.

翻译中…
  • In the initial state, every row contains one piece of the first player facing left and one piece of the second player facing right.
  • The two players alternately advance one of their pieces.
  • The player who is first to be unable to make a move loses, and the other player wins.
翻译中…

Let $(i, j)$ denote the square at the $i$-th row from the top and $j$-th column from the left. The following moves are allowed:

翻译中…
  • The first player can move a piece at $(i,j)$ to $(i,k)$ if $k \lt j$ and none of $(i,k),(i,k+1),\dots,(i,j-1)$ contains a piece of either player.
  • The second player can move a piece at $(i,j)$ to $(i,k)$ if $k \gt j$ and none of $(i,j+1),(i,j+2),\dots,(i,k)$ contains a piece of either player.
翻译中…

For example, in the figure below, on a $3\times 9$ grid, the first player's pieces are at $(1,7),(2,1),(3,4)$, and the second player's pieces are at $(1,3),(2,7),(3,5)$. The first player can move the piece at $(1,7)$ to $(1,4),(1,5)$, or $(1,6)$, and the piece at $(3,4)$ to $(3,1),(3,2)$, or $(3,3)$. The first player cannot move the piece at $(2,1)$.

翻译中…

image

翻译中…

Currently, there is no piece on the grid. There are $\left\lbrace W(W-1)\right\rbrace^H$ ways to place one piece of the first player and one piece of the second player in each row, so that no two pieces are placed at the same square. How many of them satisfy the following condition? Find the count modulo $998244353$.

翻译中…
  • When they play the game optimally from that initial state, the first player wins.
翻译中…

Constraints

翻译中…
  • $1 \leq H \leq 8000$
  • $2 \leq W \leq 30$
  • $H$ and $W$ are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

H W

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
1 3
Output #1
2
The first player can win if: - the first player's piece is placed at $(1, 3)$, and the second player's piece is placed at $(1, 1)$; or - the first player's piece is placed at $(1, 2)$, and the second player's piece is placed at $(1, 3)$.
Input #2
9 9
Output #2
583962987
Input #3
265 30
Output #3
366114675
题目信息
题号
abc265_h
时间限制
10 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。