2 2 YY XY
4
There are two possible paths $P$: $(1, 1) \to (1, 2) \to (2, 2)$ and $(1, 1) \to (2, 1) \to (2, 2)$.
* For $(1, 1) \to (1, 2) \to (2, 2)$, we have $\mathrm{str}(P) = {}$`YYY`, with two pairs of consecutive `Y`s at positions $1, 2$ and $2, 3$, so the score is $2^2 = 4$.
* For $(1, 1) \to (2, 1) \to (2, 2)$, we have $\mathrm{str}(P) = {}$`YXY`, with no pairs of consecutive `Y`s , so the score is $0^2 = 0$.
Thus, the sought sum is $4 + 0 = 4$.2 2 XY YY
2
For either of the two possible paths $P$, we have $\mathrm{str}(P) = {}$`XYY`, for a score of $1^2 = 1$.10 20 YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY
423787835 Print the sum of the scores modulo $998244353$.
{
"problem": {
"name": "YY Square",
"description": {
"content": "There is a grid with $H$ rows and $W$ columns where each square has one of the characters `X` and `Y` written on it. Let $(i, j)$ denote the square at the $i$\\-th row from the top and $j$\\-th column f",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 3000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc157_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There is a grid with $H$ rows and $W$ columns where each square has one of the characters `X` and `Y` written on it. Let $(i, j)$ denote the square at the $i$\\-th row from the top and $j$\\-th column f...",
"is_translate": false,
"language": "English"
}
]
}