AtCoder Grand Contest 056
F
Degree Sequence in DFS Order
AtCoder
⌀ 4310
原题
← E→
翻译中…

Problem Statement

翻译中…

Given are integers $N$ and $M$. Find the number of integer sequences $a=(a_1,a_2,\cdots,a_N)$ that can be generated as follows, modulo $998244353$.

翻译中…
  • Provide an undirected connected graph $G$ with $N$ vertices and $M$ edges. Here, $G$ may not contain self-loops, but may contain multi-edges.
  • Perform DFS on $G$ and let $a_i$ be the degree of the $i$-th vertex to be visited. More accurately, execute the pseudo-code below to get $a$.
翻译中…

a = empty array

dfs(v):
    visited[v]=True
    a.append(degree[v])
    for u in g[v]:
        if not visited[u]:
            dfs(u)

dfs(arbitrary root)

翻译中…

Here, the variable $g$ represents the graph $G$ as an adjacency list, where $g[v]$ is the list of vertices adjacent to the vertex $v$ in arbitrary order.

翻译中…

For example, when $N=4,M=5$, it is possible to generate $a=(2,4,1,3)$, by providing the graph $G$ as follows.

翻译中…

picture

翻译中…

Here, the numbers written on vertices represent the order they are visited in the DFS. (The DFS starts at the vertex labeled $1$.) The orange arrows show the transitions in the DFS, and the numbers next to them represent the order the edges are traversed.

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq M \leq 10^6$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
2 2
Output #1
1
The only possible result is $a=(2,2)$. Note that $G$ may have multi-edges.
Input #2
3 4
Output #2
9
Input #3
10 20
Output #3
186225754
Input #4
100000 1000000
Output #4
191021899
题目信息
题号
agc056_f
时间限制
2 s
内存限制
1024 MB

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