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  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.
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  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