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

建议使用的浏览器:

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

2186:Popular Cows

题目描述
Every cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that tell you that cow A thinks that cow B is popular. Since popularity is transitive, if A thinks B is popular and B thinks C is popular, then A will also think that C is
popular, even if this is not explicitly specified by an ordered pair in the input. Your task is to compute the number of cows that are considered popular by every other cow.
输入解释
* Line 1: Two space-separated integers, N and M

* Lines 2..1+M: Two space-separated numbers A and B, meaning that A thinks B is popular.
输出解释
* Line 1: A single integer that is the number of cows who are considered popular by every other cow.
输入样例
3 3
1 2
2 1
2 3
输出样例
1
提示
Cow 3 is the only cow of high popularity.

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 USACO 2003 Fall

源链接: POJ-2186

最后修改于 2020-10-29T06:26:02+00:00 由爬虫自动更新

共提交 1

通过率 0.0%
时间上限 内存上限
2000 65536