AtCoder Beginner Contest 259
翻译中…
Problem Statement
翻译中…
We have a grid of squares with $N$ rows arranged vertically and $N$ columns arranged horizontally. The square at the $i$-th row from the top and $j$-th column from the left has an integer label $a_{i,j}$.
Consider paths obtained by starting on one of the squares and going right or down to an adjacent square zero or more times. Find the number, modulo $998244353$, of such paths that start and end on squares with the same label.
Two paths are distinguished when they visit different sets of squares (including the starting and ending squares).
翻译中…
Constraints
翻译中…
$1 \leq N \leq 400$$1 \leq a_{i,j} \leq N^2$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
a_{1,1} \ldots a_{1,N}
\vdots
a_{N,1} \ldots a_{N,N}
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
2
1 3
3 1
Output #1
6
The following six paths satisfy the requirements. ($(i, j)$ denotes the square at the $i$-th row from the top and $j$-th column from the left. Each path is represented as a sequence of squares it visits.)
- $(1,1)$
- $(1,1)$ → $(1,2)$ → $(2,2)$
- $(1,1)$ → $(2,1)$ → $(2,2)$
- $(1,2)$
- $(2,1)$
- $(2,2)$
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。