Codeforces Round 522 (Div. 1, based on Technocup 2019 Elimination Round 3)
C
Vasya and Maximum Matching
Codeforces
未评级
原题
← BD →
翻译中…

Vasya has got a tree consisting of $n$ vertices. He wants to delete some (possibly zero) edges in this tree such that the maximum matching in the resulting graph is unique. He asks you to calculate the number of ways to choose a set of edges to remove.

翻译中…

A matching in the graph is a subset of its edges such that there is no vertex incident to two (or more) edges from the subset. A maximum matching is a matching such that the number of edges in the subset is maximum possible among all matchings in this graph.

翻译中…

Since the answer may be large, output it modulo $998244353$.

翻译中…

Input

翻译中…

The first line contains one integer $n$ ($1 \le n \le 3 \cdot 10^5$) — the number of vertices in the tree.

翻译中…

Each of the next $n − 1$ lines contains two integers $u$ and $v$ ($1 \le u, v \le n, u \neq v$) denoting an edge between vertex $u$ and vertex $v$. It is guaranteed that these edges form a tree.

翻译中…

Output

翻译中…

Print one integer — the number of ways to delete some (possibly empty) subset of edges so that the maximum matching in the resulting graph is unique. Print the answer modulo $998244353$.

翻译中…

Note

翻译中…

Possible ways to delete edges in the first example:

翻译中…
  • delete $(1, 2)$ and $(1, 3)$.
  • delete $(1, 2)$ and $(1, 4)$.
  • delete $(1, 3)$ and $(1, 4)$.
  • delete all edges.
翻译中…

Possible ways to delete edges in the second example:

翻译中…
  • delete no edges.
  • delete $(1, 2)$ and $(2, 3)$.
  • delete $(1, 2)$ and $(3, 4)$.
  • delete $(2, 3)$ and $(3, 4)$.
  • delete $(2, 3)$.
  • delete all edges.
翻译中…

样例

Input #1
4
1 2
1 3
1 4
Output #1
4
InputCopy OutputCopy
Input #2
4
1 2
2 3
3 4
Output #2
6
InputCopy OutputCopy
Input #3
1
Output #3
1
InputCopy OutputCopy
题目信息
题号
1078C
时间限制
3 s
内存限制
256 MB

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