QOJ.ac

QOJ

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

#12037. 拓扑序计数

統計

给定 $n$,定义 $f(E)$ 表示一个边集为 $E$ 的 $n$ 个点的有向图的拓扑序个数。

一张 $n$ 个点的图的一个合法拓扑序是一个 $1..n$ 的排列 $p[1...n]$,满足对于该图的所有有向边 $(u,v)$,有$p[v]>p[u]$

现在给定 $m$ 条有向边,假设这 $m$ 条边构成的集合为 $T$,求 $\sum_{E \subseteq T}f(E)$

由于答案可能很大,你只需要输出答案对 $998244353$ 取模后的值

输入格式

第一行两个整数 $n,m$

接下来 $m$ 行,每行两个整数 $u,v~(1\leq u,v\leq n)$,表示一条有向边 $(u,v)$

保证没有重边和自环

输出格式

输出答案对 $998244353$ 取模后的值

样例数据

样例 1 输入

3 2
1 2
2 3

样例 1 输出

13

子任务

$Task1~(7pts)$:$1\leq n,m\leq 5$

$Task2~(12pts)$:$1\leq n+m\leq 20$

$Task3~(16pts)$:$1\leq n\leq 9$

$Task4~(17pts)$:保证 $E$ 中的边都是 $(i , i+1)$ 的形式

$Task5~(48pts)$:无特殊限制

对于所有数据,有 $1\leq n\leq 20$,$0\leq m\leq n(n-1)$

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.