#P4017. 最大食物链计数

    ID: 2918 远端评测题 1000ms 125MiB 尝试: 4 已通过: 1 难度: 5 上传者: 标签>动态规划,dp搜索图论排序深度优先搜索,DFS拓扑排序

最大食物链计数

Description

Given a food web, you are to compute the number of maximal food chains in this food web.

(Here, a "maximal food chain" refers to a food chain in the biological sense: the leftmost end is a producer that does not prey on any other species, and the rightmost end is a consumer that is not preyed upon by any other species.)

Delia is in a hurry, so you have only 11 second.

Since the result may be large, you only need to output the total modulo 8011200280112002.

Input Format

The first line contains two positive integers nn, mm, denoting the number of species nn and the number of predator-prey relations mm.

Then mm lines follow. Each line contains two positive integers, denoting a species AA that is eaten and a species BB that eats AA.

Output Format

Output a single integer on one line: the number of maximal food chains modulo 8011200280112002.

5 7
1 2
1 3
2 3
3 5
2 5
4 5
3 4
5

Hint

Each test point satisfies the following constraints:

Test point ID nn mm
1,21,2 40\le 40 400\le 400
3,43,4 100\le 100 2×103\le 2\times 10^3
5,65,6 103\le 10^3 6×104\le 6\times 10^4
7,87,8 2×103\le 2\times 10^3 2×105\le 2\times 10^5
9,109,10 5×103\le 5\times 10^3 5×105\le 5\times 10^5

For 100%100\% of the testdata, 1n5×103,1m5×1051 \le n \le 5\times 10^3, 1 \le m \le 5\times 10^5.

Additional note: The data contains no cycles, in line with biological requirements. (Thanks to @AKEE.)

Translated by ChatGPT 5