AtCoder Regular Contest 153
F
Tri-Colored Paths
AtCoder
⌀ 3597
原题
← E→
翻译中…

Problem Statement

翻译中…

You are given a simple connected undirected graph $G$ with $N$ vertices and $M$ edges. The vertices are numbered $1$ to $N$, and the $i$-th edge connects vertices $A_i$ and $B_i$.

翻译中…

Find the number of ways to paint each edge of $G$ in color $1$, $2$, or $3$ so that the following condition is satisfied, modulo $998244353$.

翻译中…
  • There is a simple path in $G$ that contains an edge in color $1$, an edge in color $2$, and an edge in color $3$.
翻译中…

What is a simple path? A simple path is a pair of a sequence of vertices $(v_1, \ldots, v_{k+1})$ and a sequence of edges $(e_1, \ldots, e_k)$ that satisfies the following: $i\neq j \implies v_i\neq v_j$; edge $e_i$ connects vertices $v_i$ and $v_{i+1}$.

翻译中…

Constraints

翻译中…
  • $3 \leq N\leq 2\times 10^5$
  • $3 \leq M\leq 2\times 10^5$
  • $1 \leq A_i, B_i \leq N$
  • The given graph is simple and connected.
翻译中…

Input

翻译中…

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

翻译中…

N M
A_1 B_1
\vdots
A_M B_M

翻译中…

Output

翻译中…

Print the number of ways to paint each edge of $G$ in color $1$, $2$, or $3$ so that the condition in question is satisfied, modulo $998244353$.

翻译中…

样例

Input #1
3 3
1 2
1 3
3 2
Output #1
0
Any simple path in $G$ contains two or fewer edges, so there is no way to satisfy the condition.
Input #2
4 6
1 2
1 3
1 4
2 3
2 4
3 4
Output #2
534
Input #3
6 5
1 3
4 3
5 4
4 2
1 6
Output #3
144
Input #4
6 7
1 2
2 3
3 1
4 5
5 6
6 4
1 6
Output #4
1794
题目信息
题号
arc153_f
时间限制
2 s
内存限制
1024 MB

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