Codeforces Round 958 (Div. 2)
F
Heartbeat
Codeforces
3000
原题
← E→
翻译中…

For an array $u_1, u_2, \ldots, u_n$, define

翻译中…
  • a prefix maximum as an index $i$ such that $u_i \gt u_j$ for all $j \lt i$;
  • a suffix maximum as an index $i$ such that $u_i \gt u_j$ for all $j \gt i$;
  • an ascent as an index $i$ ($i \gt 1$) such that $u_i \gt u_{i-1}$.
翻译中…

You are given three cost arrays: $[a_1, a_2, \ldots, a_n]$, $[b_1, b_2, \ldots, b_n]$, and $[c_0, c_1, \ldots, c_{n-1}]$.

翻译中…

Define the cost of an array that has $x$ prefix maximums, $y$ suffix maximums, and $z$ ascents as $a_x\cdot b_y\cdot c_z$.

翻译中…

Let the sum of costs of all permutations of $1,2,\ldots,n$ be $f(n)$. Find $f(1)$, $f(2)$, ..., $f(n)$ modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first line contains an integer $n$ ($1\le n\le 700$).

翻译中…

The second line contains $n$ integers $a_1,\ldots,a_n$ ($0\le a_i \lt 998\,244\,353$).

翻译中…

The third line contains $n$ integers $b_1,\ldots,b_n$ ($0\le b_i \lt 998\,244\,353$).

翻译中…

The fourth line contains $n$ integers $c_0,\ldots,c_{n-1}$ ($0\le c_i \lt 998\,244\,353$).

翻译中…

Output

翻译中…

Print $n$ integers: the $i$-th one is $f(i)$ modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the second example:

翻译中…
  • Consider permutation $[1,2,3]$. Indices $1,2,3$ are prefix maximums. Index $3$ is the only suffix maximum. Indices $2,3$ are ascents. In conclusion, it has $3$ prefix maximums, $1$ suffix maximums, and $2$ ascents. Therefore, its cost is $a_3b_1c_2=12$.
  • Permutation $[1,3,2]$ has $2$ prefix maximums, $2$ suffix maximums, and $1$ ascent. Its cost is $6$.
  • Permutation $[2,1,3]$ has $2$ prefix maximums, $1$ suffix maximum, and $1$ ascent. Its cost is $4$.
  • Permutation $[2,3,1]$ has $2$ prefix maximums, $2$ suffix maximums, and $1$ ascent. Its cost is $6$.
  • Permutation $[3,1,2]$ has $1$ prefix maximum, $2$ suffix maximums, and $1$ ascent. Its cost is $3$.
  • Permutation $[3,2,1]$ has $1$ prefix maximum, $3$ suffix maximums, and $0$ ascents. Its cost is $3$.
翻译中…

The sum of all permutations' costs is $34$, so $f(3)=34$.

翻译中…

样例

Input #1
3
1 1 1
1 1 1
1 1 1
Output #1
1 2 6
InputCopy OutputCopy
Input #2
3
1 2 3
2 3 1
3 1 2
Output #2
6 13 34
InputCopy OutputCopy
Input #3
5
1 4 2 5 3
2 5 1 3 4
300000000 100000000 500000000 400000000 200000000
Output #3
600000000 303511294 612289529 324650937 947905622
InputCopy OutputCopy
题目信息
题号
1988F
时间限制
5 s
内存限制
512 MB
标签
组合数学
动态规划
FFT
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。