AtCoder Grand Contest 052
F
Tree Vertices XOR
AtCoder
未评级
原题
← E→
翻译中…

Problem Statement

翻译中…

You are given a tree with $N$ vertices. The vertices are numbered from $1$ to $N$, and the $i$-th edge connects vertices $u_i$ and $v_i$.

翻译中…

Initially, on each vertex of the tree is written number $1$.

翻译中…

In one operation, you can do the following:

翻译中…
  • Choose any vertex $v$ of the tree. Let $X$ be the XOR of the values written in the neighbors of $v$. Then, if the number written on $v$ is $a_v$, replace it by $(a_v\ \mathrm{XOR}\ X)$.
翻译中…

You can perform this operation any finite (maybe zero) number of times. How many configurations can you achieve? As this number can be large, output it modulo $998244353$.

翻译中…

Two configurations are called different if there exists a vertex $v$, such that the numbers written in $v$ in these configurations are different.

翻译中…

Constraints

翻译中…
  • $3 \le N \le 2\cdot 10^5$
  • $1\le u_i, v_i \le N$
  • $u_i \neq v_i$
  • The input represents a valid tree.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
u_1 v_1
u_2 v_2
\vdots
u_{N-1} v_{N-1}

翻译中…

Output

翻译中…

Output the number of configurations you can get from the initial state, modulo $998244353$.

翻译中…

样例

Input #1
4
1 2
2 3
3 4
Output #1
10
We can get the following configurations ($abcd$ means vertices $1,2,3,4$ have $a,b,c,d$ written on them): $1111$, $1110$, $1100$, $1000$, $0111$, $0110$, $0100$, $0011$, $0010$, $0001$.
Input #2
5
1 2
1 3
1 4
1 5
Output #2
24
Input #3
6
1 3
2 3
3 4
4 5
4 6
Output #3
40
Input #4
9
1 2
2 3
1 4
4 5
1 6
6 7
7 8
8 9
Output #4
255
题目信息
题号
agc052_f
时间限制
4 s
内存限制
1024 MB

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