103366: [Atcoder]ABC336 G - 16 Integers
Description
Score: $650$ points
Problem Statement
You are given $16$ non-negative integers $X_{i, j, k, l}$ $(i, j, k, l \in \lbrace 0, 1 \rbrace)$ in ascending order of $(i, j, k, l)$.
Let $N = \displaystyle \sum_{i=0}^1 \sum_{j=0}^1 \sum_{k=0}^1 \sum_{l=0}^1 X_{i,j,k,l}$.
Find the number, modulo $998244353$, of sequences $(A_1, A_2, ..., A_{N+3})$ of length $N + 3$ consisting of $0$s and $1$s that satisfy the following condition.
- For every quadruple of integers $(i, j, k, l)$ $(i, j, k, l \in \lbrace 0, 1 \rbrace)$, there are exactly $X_{i,j,k,l}$ integers $s$ between $1$ and $N$, inclusive, that satisfy:
- $A_s = i$, $A_{s + 1} = j$, $A_{s + 2} = k$, and $A_{s + 3} = l$.
Constraints
- $X_{i, j, k, l}$ are all non-negative integers.
- $1 \leq \displaystyle \sum_{i=0}^1 \sum_{j=0}^1 \sum_{k=0}^1 \sum_{l=0}^1 X_{i,j,k,l} \leq 10^6$
Input
The input is given from Standard Input in the following format:
$X_{0,0,0,0}$ $X_{0,0,0,1}$ $X_{0,0,1,0}$ $X_{0,0,1,1}$ $X_{0,1,0,0}$ $X_{0,1,0,1}$ $X_{0,1,1,0}$ $X_{0,1,1,1}$ $X_{1,0,0,0}$ $X_{1,0,0,1}$ $X_{1,0,1,0}$ $X_{1,0,1,1}$ $X_{1,1,0,0}$ $X_{1,1,0,1}$ $X_{1,1,1,0}$ $X_{1,1,1,1}$
Output
Print the number, modulo $998244353$, of sequences that satisfy the condition in the problem statement.
Sample Input 1
0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0
Sample Output 1
1
This input corresponds to the case where $X_{1, 0, 1, 0}$ and $X_{1, 1, 0, 1}$ are $1$ and all others are $0$.
In this case, only one sequence satisfies the condition, which is $(1, 1, 0, 1, 0)$.
Sample Input 2
1 1 2 0 1 2 1 1 1 1 1 2 1 0 1 0
Sample Output 2
16
Sample Input 3
21 3 3 0 3 0 0 0 4 0 0 0 0 0 0 0
Sample Output 3
2024
Sample Input 4
62 67 59 58 58 69 57 66 67 50 68 65 59 64 67 61
Sample Output 4
741536606
Input
Output
得分:650分
问题描述
给你16个非负整数$X_{i, j, k, l}$ $(i, j, k, l \in \lbrace 0, 1 \rbrace)$,按照$(i, j, k, l)$的升序排列。
设$N = \displaystyle \sum_{i=0}^1 \sum_{j=0}^1 \sum_{k=0}^1 \sum_{l=0}^1 X_{i,j,k,l}$。
求满足以下条件的0和1组成的长度为$N + 3$的序列$(A_1, A_2, ..., A_{N+3})$的数量,对998244353取模。
- 对于每一个四元组$(i, j, k, l)$ $(i, j, k, l \in \lbrace 0, 1 \rbrace)$,有恰好$X_{i,j,k,l}$个1到$N$(包括1和N)之间的整数$s$满足以下条件:
- $A_s = i$,$A_{s + 1} = j$,$A_{s + 2} = k$,$A_{s + 3} = l$。
限制条件
- $X_{i, j, k, l}$都是非负整数。
- $1 \leq \displaystyle \sum_{i=0}^1 \sum_{j=0}^1 \sum_{k=0}^1 \sum_{l=0}^1 X_{i,j,k,l} \leq 10^6$
输入
输入从标准输入按照以下格式给出:
$X_{0,0,0,0}$ $X_{0,0,0,1}$ $X_{0,0,1,0}$ $X_{0,0,1,1}$ $X_{0,1,0,0}$ $X_{0,1,0,1}$ $X_{0,1,1,0}$ $X_{0,1,1,1}$ $X_{1,0,0,0}$ $X_{1,0,0,1}$ $X_{1,0,1,0}$ $X_{1,0,1,1}$ $X_{1,1,0,0}$ $X_{1,1,0,1}$ $X_{1,1,1,0}$ $X_{1,1,1,1}$
输出
输出满足问题描述中条件的序列的数量,对998244353取模。
样例输入1
0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0
样例输出1
1
这个输入对应于$X_{1, 0, 1, 0}$和$X_{1, 1, 0, 1}$为1,其余为0的情况。
在这种情况下,只有一个序列满足条件,即$(1, 1, 0, 1, 0)$。
样例输入2
1 1 2 0 1 2 1 1 1 1 1 2 1 0 1 0
样例输出2
16
样例输入3
21 3 3 0 3 0 0 0 4 0 0 0 0 0 0 0
样例输出3
2024
样例输入4
62 67 59 58 58 69 57 66 67 50 68 65 59 64 67 61
样例输出4
741536606