パナソニックグループプログラミングコンテスト2022(AtCoder Beginner Contest 273)
翻译中…
Problem Statement
翻译中…
Find the number, modulo $998244353$, of square matrices of size $N$ whose elements are non-negative integers, that satisfy both of the following two conditions:
翻译中…
- for all
$i = 1, 2, \ldots, N$, the sum of the elements in the$i$-th row is$R_i$; - for all
$i = 1, 2, \ldots, N$, the sum of the elements in the$i$-th column is$C_i$.
翻译中…
Note that $R_i$ and $C_i$ given in the input are integers between $0$ and $2$ (see Constraints).
翻译中…
Constraints
翻译中…
$1 \leq N \leq 5000$$0 \leq R_i \leq 2$$0 \leq C_i \leq 2$- All values in the input are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
R_1 R_2 \ldots R_N
C_1 C_2 \ldots C_N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
3
1 1 1
0 1 2
Output #1
3
The following $3$ matrices satisfy the conditions:
Input #2
3
1 1 1
2 2 2
Output #2
0
Input #3
18
2 0 1 2 0 1 1 2 1 1 2 0 1 2 2 1 0 0
1 1 0 1 1 1 1 1 1 1 1 1 2 1 1 0 2 2
Output #3
968235177
Be sure to print the count modulo $998244353$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。