测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A10381. TOF

编程题 普及/提高-

题目描述

The first line of the input contains two integers $n$ and $m$ ( $1<=n,m<=5000$ ) — the number of vertices and then number of directed edges in the input graph.

Each of the next $m$ lines contains a pair of integers $u_{i}$ and $v_{i}$ ( $1<=u_{i},v_{i}<=n$ ), meaning there is a directed ![](/uploads/acgo/image/90da071e666c6de3_d0e56d8689ad.jpeg) edge in the input graph.

You may assume that the graph won't contain any self-loops and there is at most one edge between any unordered pair of vertices.

输入格式

Print a single integer — the minimum possible number of dfs calls that can be achieved with permuting the edges.

输出格式

无

输入输出样例

输入 #1
3 3
1 2
2 3
3 1
输出 #1
2998
输入 #2
6 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
输出 #2
3001
上一题 去做题 下一题