問題一覧 > 通常問題

No.2584 The University of Tree

レベル : / AI推定難易度 : 2450 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 18
作問者 : 👑 Nachia / テスター : hirayuu_yc
お気に入りにしたユーザー ProblemId : 10313 / 自分の提出
問題文最終更新日: 2023-12-12 21:59:21
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2023 (順位表) の他の問題:

Problem Statement

A school festival is being held at the national Koyaso University.

The campus of Koyaso University has $N$ plazas and $N-1$ roads. Each road connects exactly $2$ plazas. Using the $N-1$ roads, every plaza can be reached from every other plaza. The plazas are numbered from $1$ to $N$, and the roads are numbered from $1$ to $N-1$. As described below, there are also passable paths other than the roads.

Each plaza has a circular path, and the roads are connected to this path. In addition, the path of plaza $k$ is connected to base $k$ by another path. Furthermore, in plaza $k$, there is $1$ stall of type $k$ between each pair of adjacent junctions on the path. Let $C_k$ be the number of roads connected to plaza $k$. The numbers of these roads are $E_{k,1},E_{k,2},\ldots ,E_{k,C_k}$ in counterclockwise order, starting from the direction of base $k$.

Due to traffic restrictions for the festival, the circular path of each plaza can only be traversed counterclockwise. All other paths can be traversed in both directions.

Also, once you leave a base, you are not allowed to visit the same point on a path $2$ or more times until you next arrive at a base.

As an illustration of the above, the figure below shows the surroundings of plaza $k$ in the case $C_k=4$. Here, the black circles represent stalls of type $k$, the house symbol represents base $k$, and the blue lines represent passable paths.

Then, given $2$ distinct bases $s,t$, the combination of stalls passed through when moving from base $s$ to base $t$ without visiting a base along the way is uniquely determined, in exactly $1$ way. Let $p(s,t)$ be the product of the type numbers of all stalls passed through when moving from base $s$ to base $t$. If $s=t$, let $p(s,t)=0$.

For $s=1,2,3,\ldots ,N$, define the non-negative integer $Q_s$ by $\displaystyle Q_s = \sum _ {t=1} ^ N p(s,t)$. Find $Q_s$ modulo $998\,244\,353$.

Constraints

The input satisfies the following constraints.

  • $2\leq N \leq 200\, 000$
  • $1 \leq E_{i,j} \leq N-1$
  • $E_{i,j} \neq E_{i,k}$ $(1 \leq i \leq N , 1 \leq j \lt k \leq C_i)$ That is, the same road is never connected $2$ or more times to $1$ plaza.
  • Among the values $E_{i,j}$ $(1 \leq i \leq N, 1 \leq j \leq C_i)$, each of $1,2,\ldots ,N-1$ appears exactly $2$ times.
  • Every plaza can be reached from every other plaza.
  • All input values are integers.

Input

$N$
$C_1$ $E_{1,1}$ $E_{1,2}$ $\cdots$ $E_{1,C_1}$
$C_2$ $E_{2,1}$ $E_{2,2}$ $\cdots$ $E_{2,C_2}$
$\vdots$
$C_N$ $E_{N,1}$ $E_{N,2}$ $\cdots$ $E_{N,C_N}$

Output

Output $N$ lines. On the $k$-th line, output the non-negative integer $Q_k$ modulo $998\,244\,353$.

Print a newline at the end.

Sample

Sample 1
Input
3
1 1
2 2 1
1 2
Output
14
10
18
  • $p(1,2)=1\times 2 = 2$
  • $p(1,3)=1\times 2\times 2\times 3 = 12$
  • $p(2,1)=2\times 2\times 1 = 4$
  • $p(2,3)=2\times 3 = 6$
  • $p(3,1)=3\times 2\times 1 = 6$
  • $p(3,2)=3\times 2\times 2 = 12$
Sample 2
Input
15
1 5
1 2
1 7
1 10
2 3 13
1 6
3 9 14 1
1 8
1 11
2 12 4
3 11 9 5
4 12 10 1 6
3 14 2 7
2 4 13
2 3 8
Output
743667836
84291977
585649374
632812636
365914125
717110537
615240013
958498877
286325816
218888254
793603390
661716014
706115485
2736943
99495022

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。