QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 256 MB Total points: 100

#12036. 线弦图

Statistics

九条可怜是一个热爱图论的女孩子,今天她给大家带来一道有趣的图论题。

为了补充大家的图论水平,可怜首先给出了一些简单的定义。

无向图 $G = \langle V,E \rangle$ 是弦图当且仅当对于任意 $k \geq 4$,$G$ 中不存在 $k$ 元的纯环。$G$ 中的 $k$ 元纯环是一个满足如下两个条件的节点的序列 $a_1, \dots, a_k$ :

  1. $a_i$ 两两不同。
  2. $a_i,a_j$ 之间有边当且仅当他们在序列中相邻,即 $i = j \text{ mod } k + 1$ 或者 $j = i \text{ mod }k + 1$。

对于无向图 $G = ⟨V, E⟩$,它的线图 $L(G)$ 也是一个无向图:

  1. 它的点集大小为 $E$,第 $i$ 个点对应着图中的第 $i$ 条边。
  2. 两个点之间有边当且仅当这两个点对应的边在原图上有公共点(注意不会有自环)。

弦图和线图都是广为人知的定义,相信大家都做过很多关于它们的题。为了让题目变得更有趣一些,可怜定义了线弦图:无向图 $G$ 是线弦图当且仅当 $L(G)$ 是弦图。

为了让题目是一道计数题,可怜随便编了一个关于线弦图的计数问题:

给出一棵 $n$ 个点的树,你可以在上面任意加无向边,问有多少种方案可以得到无重边无自环的线弦图。

两种方案是不同的当且仅当存在一条边 $(i,j)$ 恰好只在其中一种方案中出现。

输入格式

第一行输入一个整数 $n$ 表示树上的节点个数。

接下来 $n-1$ 行每行两个整数 $u,v$ 表示树上的一条边。

输出格式

输出一行一个整数,表示答案对 $998244353$ 取模后的结果。

样例数据

样例 1 输入

3
1 2
1 3

样例 1 输出

2

样例 2 输入

4
1 2
1 3
1 4

样例 2 输出

4

样例 3 输入

6
1 2
1 3
2 4
2 5
2 6

样例 3 输出

14

子任务

本题分为 $3$ 个子任务,你需要通过所有子任务中的所有测试点,才能拿到这个子任务的分数:

子任务一($19$ 分),$n \leq 9$。

子任务二($39$ 分),$n \leq 3000$。

子任务三($42$ 分),$n \leq 2 \times 10^5$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.