CF1332F.Independent Set

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Eric is the teacher of graph theory class. Today, Eric teaches independent set and edge-induced subgraph.

Given a graph G=(V,E)G=(V,E) , an independent set is a subset of vertices VVV' \subset V such that for every pair u,vVu,v \in V' , (u,v)∉E(u,v) \not \in E (i.e. no edge in EE connects two vertices from VV' ).

An edge-induced subgraph consists of a subset of edges EEE' \subset E and all the vertices in the original graph that are incident on at least one edge in the subgraph.

Given EEE' \subset E , denote G[E]G[E'] the edge-induced subgraph such that EE' is the edge set of the subgraph. Here is an illustration of those definitions:

In order to help his students get familiar with those definitions, he leaves the following problem as an exercise:

Given a tree G=(V,E)G=(V,E) , calculate the sum of w(H)w(H) over all except null edge-induced subgraph HH of GG , where w(H)w(H) is the number of independent sets in HH . Formally, calculate EEw(G[E])\sum \limits_{\emptyset \not= E' \subset E} w(G[E']) .

Show Eric that you are smarter than his students by providing the correct answer as quickly as possible. Note that the answer might be large, you should output the answer modulo 998,244,353998,244,353 .

输入格式

The first line contains a single integer nn ( 2n31052 \le n \le 3 \cdot 10^5 ), representing the number of vertices of the graph GG .

Each of the following n1n-1 lines contains two integers uu and vv ( 1u,vn1 \le u,v \le n , uvu \not= v ), describing edges of the given tree.

It is guaranteed that the given edges form a tree.

输出格式

Output one integer, representing the desired value modulo 998,244,353998,244,353 .

输入输出样例

  • 输入#1

    2
    2 1

    输出#1

    3
  • 输入#2

    3
    1 2
    3 2

    输出#2

    11

说明/提示

For the second example, all independent sets are listed below.

首页