2 2 4 3 3 4
2 $(A_1, A_2) = (4, 3)$ and $(B_1, B_2) = (3, 4)$. In this case, there are two ways to write the numbers, as follows: * $1$ in $(1, 1)$, $4$ in $(1, 2)$, $3$ in $(2, 1)$ and $2$ in $(2, 2)$. * $2$ in $(1, 1)$, $4$ in $(1, 2)$, $3$ in $(2, 1)$ and $1$ in $(2, 2)$. Here, $(i, j)$ denotes the square at the $i$\-th row and the $j$\-th column.
3 3 5 9 7 3 6 9
0 Since there is no way to write the numbers under the condition, $0$ should be printed.
2 2 4 4 4 4
0
14 13 158 167 181 147 178 151 179 182 176 169 180 129 175 168 181 150 178 179 167 180 176 169 182 177 175 159 173
343772227
{
"problem": {
"name": "Double Landscape",
"description": {
"content": "Consider writing each of the integers from $1$ to $N \\times M$ in a grid with $N$ rows and $M$ columns, without duplicates. Takahashi thinks it is not fun enough, and he will write the numbers under t",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "keyence2019_d"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Consider writing each of the integers from $1$ to $N \\times M$ in a grid with $N$ rows and $M$ columns, without duplicates. Takahashi thinks it is not fun enough, and he will write the numbers under t...",
"is_translate": false,
"language": "English"
}
]
}