2 3 XYY YXY
2
Below are the eight ways to set up fences.
X Y Y X|Y Y X Y|Y X|Y|Y
| | | |
Y X Y Y|X Y Y X|Y Y|X|Y
X Y Y X|Y Y X Y|Y X|Y|Y
----- -+--- ---+- -+-+-
Y X Y Y|X Y Y X|Y Y|X|Y
For instance, if a fence is set up between the $2$\-nd and $3$\-rd columns, the blocks are:
XY
YX
Y
Y
Each of these blocks has exactly two `Y`s, so the condition is satisfied.
If a fence is set up between the $1$\-st and $2$\-nd rows and the $1$\-st and $2$\-nd columns, the blocks are:
X
YY
Y
XY
These blocks, except the second, do not have exactly two `Y`s, so the condition is not satisfied.2 3 XYX YYY
0 There is no way to set up fences to satisfy the condition.
2 58 YXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXY YXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXYXXY
164036797 Print the number of ways modulo $998244353$.
{
"problem": {
"name": "YY Garden",
"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_d"
},
"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"
}
]
}