問題一覧 > 通常問題

No.3563 No T-Junctions in Kyoto

レベル : / AI推定難易度 : 1450 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 32
作問者 : soryuusi0219 / テスター : 👑 みうね fluorine TKTYI HoyHoyCharhang jastaway yaaya butsurizuki wasab1 tatesoto KumaTachiRen
お気に入りにしたユーザー ProblemId : 13380 / 自分の提出
問題文最終更新日: 2026-08-15 03:08:22
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
KCPC新歓杯2026 (順位表) の他の問題:

Problem Statement

Kyoto City consists of $N \times M$ blocks arranged in a grid with $N$ rows running north to south and $M$ columns running east to west. The city is to be divided into several special wards.

Each special ward must be connected in the north, south, east, and west directions. That is, for any 2 blocks belonging to the same special ward, it must be possible to travel between them by moving only through blocks of that ward that are adjacent by sharing an edge.

When adjacent blocks belong to different special wards, a main road separating the blocks is built along their boundary. However, to prevent traffic congestion, no T-junction may be created in the interior of the grid. That is, at any intersection in the interior of the grid, the number of main roads connected to it must not be exactly $3$.

Find the total number of divisions into special wards satisfying the conditions, modulo $998244353$. Here, 2 ways of dividing are considered the same division if and only if, for any 2 blocks, whether those blocks belong to the same special ward agrees between them.

Input

The input is given from Standard Input in the following format.

$N$ $M$
  • $1 \le N, M \le 3000$
  • All input values are integers.

Partial Score

This problem has partial scoring based on subtasks.

SubtaskScoreConstraints
部分点110% (30 pts)$N = 1$
満点90% (270 pts)追加の制約はない

Output

Output the answer on $1$ line.

Sample

Sample 1
Input
2 2
Output
8

There are the following $8$ ways to divide the $2 \times 2$ blocks into special wards so that no T-junction is created in the interior.

For example, if the blocks are divided into 3 special wards as shown below, 3 main roads meet at the central intersection, creating a T-junction, so the conditions are not satisfied.

Sample 2
Input
1 1
Output
1

Since there is only $1$ block, there is only $1$ way: making the whole city $1$ special ward without dividing it. There are no intersections in the interior, so no T-junction can be created.

Sample 3
Input
2026 529
Output
996014394

Note that you should find the remainder modulo $998244353$.

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