题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3836
Problem Description
To prove two sets A and B are equivalent, we can first prove A is a subset of B, and then prove B is a subset of A, so finally we got that these two sets are equivalent.
You are to prove N sets are equivalent, using the method above: in each step you can prove a set X is a subset of another set Y, and there are also some sets that are already proven to be subsets of some other sets.
Now you want to know the minimum steps needed to get the problem proved.
Input
The input file contains multiple test cases, in each case, the first line contains two integers N <= 20000 and M <= 50000.
Next M lines, each line contains two integers X, Y, means set X in a subset of set Y.
Output
For each case, output a single integer: the minimum steps needed.
Sample Input
Sample Output
4
2
Hint
Case 2: First prove set 2 is a subset of set 1 and then prove set 3 is a subset of set 1.
Source
Recommend
xubiao
求强连通分量,然后统计每一个分量的入读和初读
这两个量中较大的那一个就是答案了。
分享到:
相关推荐
ACM ICPC HDOJ1000
收集的部分HDOJ杭电ACM题的代码 大牛勿下 全是基础供初级acmer使用
杭电acm解题报告 详细解析2000-2099 适合acm初学者
自己积累的部分杭电oj的(hdu)解题代码。。大家有空来看看。 基本上是自己写的哈。有错误之处请指教、
HDOJ题目分类HDOJ题目分类HDOJ题目分类
杭州电子科技大学hdoj1002,大整数相加问题
ACM ICPC HDOJ1002
ACM ICPC HDOJ1001
hdoj1001标程
hdoj上的资源,代码有注释,很不错的哦
杭电oj4405,一道简单的概率dp题目
hdoj1004,解题代码,答案代码,欢迎下载
ACM ICPC HDOJ1003
ACM ICPC HDOJ1008
杭州电子科大HDOJ
c语言 最短路 是hdoj上的一个最短路问题,写的很牛
hdoj解题代码,题目为1000-1050
hdoj的一些题目分类,由hdu大牛搜集,希望对做ac的同志们有帮助
一些HDOJ上的DP题目的小总结,但愿能帮到那些想专攻DP的人吧
codj,hdoj的源码(50-60题)