#abc253h. Ex - We Love Forest

Ex - We Love Forest

Score : 600600 points

问题描述

我们有一个图 GG,包含 NN 个顶点,编号为 11NN,且当前有 00 条边。你得到两个长度为 MM 的序列:u=(u1,u2,,uM)u=(u_1,u_2,\ldots,u_M)v=(v1,v2,,vM)v=(v_1,v_2,\ldots,v_M)

你将执行以下操作 (N1)(N-1) 次:

  • 随机均匀选择一个索引 ii1iM1 \leq i \leq M)。在 GG 中添加一条连接顶点 uiu_iviv_i 的无向边。

注意,即使 GG 已经存在一条或多条连接顶点 uiu_iviv_i 的边,上述操作也会添加一条新的边。换句话说,最终得到的 GG 可能包含多条边。

对于每个 K=1,2,,N1K=1,2,\ldots,N-1,求出在第 KK 次操作后,GG 是森林的概率对 998244353998244353 取模的结果。

什么是森林?

没有环的无向图被称为森林。森林不一定连通。

概率对 998244353998244353 取模的定义

我们可以证明所求概率始终是一个有理数。此外,在本题的约束条件下,可以保证当所求概率表示为不可约分数 yx\frac{y}{x} 时,xx 不会被 998244353998244353 整除。

因此,我们可以唯一确定一个整数 zz,满足 0z9982443520 \leq z \leq 998244352(包含边界),使得 xzy(mod998244353)xz \equiv y \pmod{998244353}。请输出这个 zz 值。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We have a graph GG with NN vertices numbered 11 through NN and 00 edges. You are given sequences u=(u1,u2,,uM),v=(v1,v2,,vM)u=(u_1,u_2,\ldots,u_M),v=(v_1,v_2,\ldots,v_M) of length MM.

You will perform the following operation (N1)(N-1) times.

  • Choose ii (1iM)(1 \leq i \leq M) uniformly at random. Add to GG an undirected edge connecting Vertices uiu_i and viv_i.

Note that the operation above will add a new edge connecting Vertices uiu_i and viv_i even if GG already has one or more edges between them. In other words, the resulting GG may contain multiple edges.

For each K=1,2,,N1K=1,2,\ldots,N-1, find the probability, modulo 998244353998244353, that GG is a forest after the KK-th operation.

What is a forest?

An undirected graph without a cycle is called a forest. A forest is not necessarily connected.

Definition of probability modulo 998244353998244353

We can prove that the sought probability is always a rational number. Moreover, under the Constraints of this problem, it is guaranteed that, when the sought probability is represented by an irreducible fraction yx\frac{y}{x}, xx is indivisible by 998244353998244353.

Then, we can uniquely determine an integer zz between 00 and 998244352998244352 (inclusive) such that xzy(mod998244353)xz \equiv y \pmod{998244353}. Print this zz.

Constraints

  • 2N142 \leq N \leq 14
  • N1M500N-1 \leq M \leq 500
  • 1ui,viN1 \leq u_i,v_i \leq N
  • uiviu_i\neq v_i
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

u1u_1 v1v_1

\vdots

uMu_M vMv_M

Output

Print N1N-1 lines. The ii-th line should contain the probability, modulo 998244353998244353, that GG is a forest after the ii-th operation.

Sample Input 1

3 2
1 2
2 3

Sample Output 1

1
499122177

Let us denote by (u,v)(u, v) the edge connecting Vertices uu and vv.

After the 11-st operation, GG will have:

  • Edge (1,2)(1, 2) with a probability of 1/21/2;
  • Edge (2,3)(2, 3) with a probability of 1/21/2.

In both cases, GG is a forest, so the answer for K=1K=1 is 11.

After the 22-nd operation, GG will have:

  • Edges (1,2)(1, 2) and (1,2)(1, 2) with a probability of 1/41/4;
  • Edges (2,3)(2, 3) and (2,3)(2, 3) with a probability of 1/41/4;
  • Edges (1,2)(1, 2) and (2,3)(2, 3) with a probability of 1/21/2.

GG is a forest only when GG has Edges (1,2)(1, 2) and (2,3)(2, 3). Therefore, the sought probability is 1/21/2; when represented modulo 998244353998244353, it is 499122177499122177, which should be printed.

Sample Input 2

4 5
1 2
1 2
1 4
2 3
2 4

Sample Output 2

1
758665709
918384805

update @ 2024/3/10 10:48:57