当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3836:Equivalent Sets

题目描述
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.
输入解释
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.
输出解释
For each case, output a single integer: the minimum steps needed.
输入样例
4 0
3 2
1 2
1 3
输出样例
4
2
提示
Case 2: First prove set 2 is a subset of set 1 and then prove set 3 is a subset of set 1.
来自杭电HDUOJ的附加信息
Recommend xubiao

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3836

最后修改于 2020-10-25T23:07:25+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
12000/4000MS(Java/Others) 104857/104857K(Java/Others)