NOMURA プログラミングコンテスト 2021 (AtCoder Regular Contest 121)
F
Logical Operations on Tree
AtCoder
⌀ 2940
原题
← E→
翻译中…

Problem Statement

翻译中…

Given is a tree with $N$ vertices numbered $1$ through $N$.

翻译中…

The $i$-th edge connects Vertices $a_i$ and $b_i$.

翻译中…

Snuke will label each vertex with 0 or 1 and each edge with AND or OR. Among the $2^{2N-1}$ ways to label the vertices and edges, find the number of ways that satisfy the following condition, modulo $998244353$.

翻译中…

Condition: There exists a sequence of $N-1$ operations ending up with one vertex labeled 1, where each operation consists of the steps below.

翻译中…
  • Choose one edge and contract it. Here, let $x$ and $y$ be the labels of the erased vertices and $\mathrm{op}$ be the label of the erased edge.
  • If $\mathrm{op}$ is AND, label the new vertex with $\mathrm{AND}(x,y)$; if $\mathrm{op}$ is OR, label the new vertex with $\mathrm{OR}(x,y)$.
翻译中…

Note

翻译中…
  • The operation $\mathrm{AND}$ is defined as follows: $\mathrm{AND}(0,0)=(0,1)=(1,0)=0,\mathrm{AND}(1,1)=1$.
  • The operation $\mathrm{OR}$ is defined as follows: $\mathrm{OR}(1,1)=(0,1)=(1,0)=1,\mathrm{OR}(0,0)=0$.
  • When contracting the edge connecting Vertex $s$ and Vertex $t$, we merge the two vertices while removing that edge. After the contraction, there is an edge connecting the new vertex and vertex $u$ if and only if there was an edge connecting $s$ and $u$ or connecting $t$ and $u$ before the contraction.
翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $2 \leq N \leq 10^{5}$
  • $1 \leq a_i, b_i \leq N$
  • The given graph is a tree.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
a_1 b_1
\vdots
a_{N-1} b_{N-1}

翻译中…

Output

翻译中…

Print the number of ways to label the tree that satisfy the condition in Problem Statement, modulo $998244353$.

翻译中…

样例

Input #1
2
1 2
Output #1
4
Input #2
20
7 3
20 18
16 12
7 2
10 5
18 16
16 3
4 11
7 15
8 1
6 1
12 13
15 5
19 17
7 1
9 8
7 17
16 14
11 7
Output #2
283374562
- Remember to print the count modulo $998244353$.
题目信息
题号
arc121_f
时间限制
2 s
内存限制
1024 MB

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