题库练习 TOF
← 上一题 下一题 →

A10381 | TOF

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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
C++ 编辑器
输入
输出