AT_arc230_a.Meeting on Tree

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given a tree with NN vertices numbered 1,2,…,N1,2,\dots, N. For i=1,2,…,N−1i=1,2,\dots, N-1, the ii-th edge connects vertices uiu_i and viv_i.

There is one squirrel at each vertex of the tree. The squirrels are trying to hold a meeting as follows.

  1. Choose one or more squirrels to participate in the meeting.

  2. The chosen squirrels consult with each other and choose one vertex of the tree as the venue for the meeting.

  3. Each of the chosen squirrels moves along the edges of the tree until it reaches the venue.

A squirrel's movement incurs a cost equal to the number of edges it traverses. We define the cost of the meeting as the sum of the movement costs of the chosen squirrels. The squirrels want to choose the venue of the meeting so that the cost of the meeting is minimized.

There are 2N−12^N-1 ways to choose one or more squirrels to participate in the meeting. Find the sum, modulo 998244353998244353, over all of these ways, of the minimum cost of the meeting when the venue is chosen appropriately.

给你一棵包含 NN 个顶点的树,顶点编号为 1,2,…,N1,2,\dots, N。对于 i=1,2,…,N−1i=1,2,\dots, N-1,第 ii 条边连接顶点 uiu_i 和 viv_i。

树的每个顶点上各有一只松鼠。这些松鼠要按如下方式举行一次会议:

  1. 选出一只或更多松鼠参与会议。

  2. 被选中的松鼠相互协商,共同选定树上的一个顶点作为会议地点。

  3. 每只被选中的松鼠沿着树的边移动,直至抵达会议地点。

一只松鼠的移动代价等于它所经过的边数。我们将会议的代价定义为所有被选中松鼠的移动代价之和。松鼠希望选择合适的会议地点,使得会议代价最小。

共有 2N−12^N-1 种方式选出一只或更多松鼠参与会议。请计算:对所有这些方式,当会议地点被最优选择时,会议的最小代价之和,并对 998244353998244353 取模。

输入格式

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

NN
u1u_1 v1v_1
u2u_2 v2v_2
⋮\vdots
uN−1u_{N-1} vN−1v_{N-1}

输入从标准输入中按以下格式给出:

NN
u1u_1 v1v_1
u2u_2 v2v_2
⋮\vdots
uN−1u_{N-1} vN−1v_{N-1}

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    4
    1 2
    1 3
    1 4

    输出#1

    21
  • 输入#2

    5
    1 2
    2 3
    3 4
    3 5

    输出#2

    70
  • 输入#3

    12
    1 2
    1 3
    3 4
    4 5
    3 6
    6 7
    6 8
    1 9
    9 10
    10 11
    9 12

    输出#3

    43813

说明/提示

Sample 1 Explanation:
For example, if the squirrels at vertices 1,2,31,2,3 participate in the meeting, it is appropriate to choose vertex 11 as the venue, and the cost in this case is 22.

The sum, over all 24−1=152^4-1=15 ways of choosing the squirrels, of the minimum cost of the meeting when the venue is chosen appropriately is 2121.

Constraints

  • 2≤N≤3×1052\le N\le 3\times 10^5
  • 1≤ui,vi≤N1\le u_i,v_i\le N
  • The given graph is a tree.
  • All input values are integers.

样例 1 解释:
例如,若顶点 1,2,31,2,3 处的松鼠参加聚会,则选择顶点 11 作为会场是合适的,此时花费为 22。

对所有 24−1=152^4-1=15 种松鼠参与方式,分别选取最优会场所得到的最小花费之和为 2121。

约束条件

  • 2≤N≤3×1052\le N\le 3\times 10^5
  • 1≤ui,vi≤N1\le u_i,v_i\le N
  • 给定图是一棵树。
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页