問題一覧 > 通常問題

No.2003 Frog on Grid

レベル : / AI推定難易度 : 2100 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 25
作問者 : 👑 to-omer / テスター : 👑 hamamu ygussany
お気に入りにしたユーザー ProblemId : 7716 / 自分の提出
問題文最終更新日: 2022-07-05 22:14:19
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 351 (順位表) の他の問題:

Problem Statement

There is a grid with $H$ rows and $W$ columns. The cell in the $i$-th row from the top and the $j$-th column from the left is denoted by $(i,j)$.

When the frog's current cell is $(x,y)$, in one jump it can move to any cell $(x+a,y+b)$ within the grid that satisfies all of the following conditions.

  • $a, b$ are non-negative integers
  • $1\le a+b\le K$

However, some cells are holes, and the frog cannot move to those cells. If $c_{i,j}$ is #, cell $(i,j)$ is a hole, and if it is ., it is not. It is guaranteed that cell $(1,1)$ and cell $(H,W)$ are not holes.

Find the number of paths along which the frog can move from $(1,1)$ to $(H,W)$. Since the answer can be very large, find it modulo $998244353$.

Constraints

  • $H,W,K$ are positive integers.
  • $2\le \textcolor{red}{HW}\le 10^6$
  • $1\le K \le H+W-2$
  • $c_{i,j}$ is . or #.
  • $c_{1,1}$ and $c_{H,W}$ are ..

Input

$H$ $W$ $K$
$c_{1,1}c_{1,2}\dots c_{1,W}$
$c_{2,1}c_{2,2}\dots c_{2,W}$
$\vdots$
$c_{H,1}c_{H,2}\dots c_{H,W}$

Output

Print on 1 line the number of paths along which the frog can move from $(1,1)$ to $(H,W)$, modulo $998244353$.

Sample

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

There are the following 6 paths.

  • $(1,1)\to(1,2)\to(1,3)\to(2,3)\to(3,3)$
  • $(1,1)\to(1,2)\to(1,3)\to(3,3)$
  • $(1,1)\to(1,2)\to(2,3)\to(3,3)$
  • $(1,1)\to(1,3)\to(2,3)\to(3,3)$
  • $(1,1)\to(1,3)\to(3,3)$
  • $(1,1)\to(3,1)\to(3,3)$
Sample 2
Input
5 4 3
...#
.###
#...
###.
.#..
Output
53
Sample 3
Input
4 7 9
.......
.......
.......
.......
Output
6080

Find the answer modulo $998244353$.

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