QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#10348. A+B Problem

Statistics

题目名字是吸引你点进来的~~~

JOHNKRAM最近在研究图论。今天他遇到了这样一道题:给一张有向图,保证没有重边和自环。求把这张图的强连通分量缩成点之后,有多少个点入度为$0$。

JOHNKRAM使用 tarjan 算法轻而易举地切掉了这道题。但他发现有很多人代码写得比他短多了,于是他要来了程序,结果发现这个程序是打印$1$的= =。难道随机数据真的这么水吗?于是他随机生成了很多张有向图,结果他发现答案真的全是$1$= =。于是他更改了随机生成的方式,只生成每个强连通分量大小都属于某个集合$S$的有向图,结果答案立刻就变大了。

现在JOHNKRAM把那些人都卡掉了,但他想证明一下数据的强度,所以他提出了一个问题:对于所有带标号点数为$i(1\leq i\leq n)$的每个强连通分量大小都属于集合$S$的有向图,之前问题的答案的期望是多少?他发现自己不会证明了,于是他来向你请教。

输入格式

输入第一行包含$1$个正整数$n$,表示生成的有向图的最大点数。

接下来$n$行,第$i$行包含一个整数$s_i$。如果$s_i=1$,则$i$在集合$S$中,否则$i$不在集合$S$中。

输出格式

共输出$n$行,每行包含一个整数。第$i$行的整数表示对于所有带标号点数为$i(1\leq i\leq n)$的每个强连通分量大小都属于集合$S$的有向图,之前问题的答案的期望$mod\ 998244353$的结果,如果没有合法的有向图则输出$0$。设期望值为$a/b$($a$和$b$为互质的正整数),你输出的整数为$x$,则你需要保证$bx\equiv a(mod\ 998244353)$且$0\leq x < 998244353$。

样例数据

样例输入

3
1
0
0

样例输出

1
332748119
519087065

样例说明

点数为$1$的有向图中,答案为$1$的合法有向图有$1$张,所以答案为$1$,$mod\ 998244353$后为$1$。

点数为$2$的有向图中,答案为$1$的合法有向图有$2$张,答案为$2$的合法有向图有$1$张,所以答案为$\frac{4}{3}$,$mod\ 998244353$后为$332748119$。

点数为$3$的有向图中,答案为$1$的合法有向图有$15$张,答案为$2$的合法有向图有$9$张,答案为$3$的合法有向图有$1$张,所以答案为$\frac{36}{25}$,$mod\ 998244353$后为$519087065$。

数据规模和约定

对于全部测试数据,$1\leq n\leq 100000$,$0\leq s_i\leq 1$。

测试点编号 $n\leq$ 其他约定
1 4
2 1000 $\forall 1\leq i\leq \lceil \frac{n}{2}\rceil ,s_i=0$
3 1000 $\forall 1\leq i\leq n,s_i=[i==1]$
4 1000 $\forall 1\leq i\leq n,s_i=[i==1]$
5 1000 $\forall 1\leq i\leq n,s_i=[i==1]$
6 1000 $\forall 1\leq i\leq \lceil \frac{n}{3}\rceil ,s_i=0$
7 1000 $\forall 1\leq i\leq \lceil \frac{n}{3}\rceil ,s_i=0$
8 1000 $\forall 1\leq i\leq \lceil \frac{n}{3}\rceil ,s_i=0$
9 1000 $\exists x,\forall 1\leq i\leq n,s_i=[i==x]$
10 1000 $\exists x,\forall 1\leq i\leq n,s_i=[i==x]$
11 1000 $\exists x,\forall 1\leq i\leq n,s_i=[i==x]$
12 1000
13 1000
14 1000
15 100000
16 100000
17 100000
18 100000
19 100000
20 100000
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.