#A. [CEOI2019] Amusement Park

    Type: RemoteJudge 3000ms 1024MiB

[CEOI2019] Amusement Park

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

有一个含 nn 个点,mm 条边的有向图,图无重边,无自环,两点之间不成环。

现在我们想改变一些边的方向,使得该有向图无环。

您需要求出,每一种改变方向后使得该有向图无环的方案的需改变边的数量之和 mod 998244353\bmod\ 998244353 之后的答案。

输入格式

第一行为两个整数 n,mn,m

接下来 mm 行,一行两个整数 ai,bia_i,b_i,表示有一条起点为 aia_i,终点为 bib_i 的有向边。

输出格式

仅一行一个整数,表示每一种改变方向后使得该有向图无环的方案的需改变边的数量之和 mod 998244353\bmod\ 998244353 之后的答案。

2 1
1 2

1

3 3
1 2
2 3
1 3
9

提示

样例解释

样例 1 解释

有如下两种方案:

  • 改变方向。
  • 不改变方向。

所以输出 1+0=11+0=1

样例 2 解释

共有六种可行的方案:

  • 12,23,131\to2,2\to3,1\to3
  • 12,32,131\to2,3\to2,1\to3
  • 12,32,311\to2,3\to2,3\to1
  • 21,23,132\to1,2\to3,1\to3
  • 21,23,312\to1,2\to3,3\to1
  • 21,32,312\to1,3\to2,3\to1

所以输出 0+1+2+1+2+3=90+1+2+1+2+3=9

数据范围

对于 100%100\% 的数据,保证 1n181\le n\le 180mn×(n1)20\le m\le \frac{n\times (n-1)}{2}1ai,bin1\le a_i,b_i\le naibia_i\not=b_i,对于 iji\not=j,均有 aiaja_i\not=a_j 或者 bibjb_i\not=b_j,无序数对 {ai,bi}\{a_i,b_i\} 互不相同。

详细子任务限制及分值如下表:

子任务编号 限制 分值
1 n3n\le 3 77
2 n6n\le 6 1212
3 n10n\le 10 2323
4 n15n\le 15 2121
5 无特殊限制 3737

说明

本题译自 Central-European Olympiad in Informatics 2019 Day 2 T1 Amusement Park

赛前十题

Not Attended
Status
Done
Rule
IOI
Problem
10
Start at
2023-10-19 7:00
End at
2023-10-21 7:00
Duration
48 hour(s)
Host
Partic.
46