AtCoder Regular Contest 155
F
Directable as Desired
AtCoder
未评级
原题
← E→
翻译中…

Problem Statement

翻译中…

You are given a sequence of $N$ non-negative integers: $D=(D_1, D_2, \dots, D_N)$.

翻译中…

Find the number of labeled trees with $N$ vertices numbered $1$ to $N$ that satisfy the following condition, modulo $998244353$.

翻译中…
  • There is a way to direct the $N-1$ edges so that the outdegree of each vertex $i\ (1\leq i \leq N)$ is $D_i$.
翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 2 \times 10^5$
  • $0 \leq D_i \leq N-1$
  • $\sum_{i=1}^{N} D_i = N-1$
  • All values in the input are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
D_1 D_2 \dots D_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
4
0 1 0 2
Output #1
5
Below are the five trees that satisfy the condition, directed in a desired way. ![image](https://img.atcoder.jp/arc155/5b5b99752b5330a2dd41607c3946fdd4.jpg)
Input #2
5
0 1 1 1 1
Output #2
125
Input #3
15
0 0 0 0 0 0 0 1 1 1 1 1 2 3 4
Output #3
63282877
题目信息
题号
arc155_f
时间限制
5 s
内存限制
1024 MB

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