#P3183. [HAOI2016] 食物链
[HAOI2016] 食物链
Description

The figure shows a schematic food web of an ecosystem. You are given species and energy-flow relations; compute the number of food chains. Species are labeled from to . The energy-flow relations are given as pairs $a_1, b_1, a_2, b_2, a_3, b_3, \ldots, a_{m-1}, b_{m-1}, a_m, b_m$, where and mean that energy flows from species to species . Note that a single isolated species does not count as a food chain.
Input Format
The first line contains two integers . The next lines each contain two integers and describing the energy-flow relations.
Output Format
Output a single integer: the number of food chains in the food web.
10 16
1 2
1 4
1 10
2 3
2 5
4 3
4 5
4 8
6 5
7 6
7 9
8 5
9 8
10 6
10 7
10 9
9
Hint
The testdata guarantee that the input conforms to biological properties, and there are no duplicate energy-flow relations. The answer is guaranteed not to overflow a 32-bit signed int.
Constraints: for of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号