poj 2186 Popular Cows
2015-06-13 15:56
393 查看
Language: Default 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. Input * 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. Output * Line 1: A single integer that is the number of cows who are considered popular by every other cow. Sample Input 3 3 1 2 2 1 2 3 Sample Output 1 Hint Cow 3 is the only cow of high popularity. #include <iostream> |
相关文章推荐
- linux驱动工程面试必问知识点
- LAMP搭建完整总结
- Nginx安装部署(完善版)
- 几个Linux驱动面试题
- 14.3英语字典(没创建,只是看到运行出来了OPEN ERROR)
- linux中的5个权限位个代表什么
- shell学习第十一天----sed正则的精确控制
- 从零开始学习OpenWrt完美教程
- dnw for linux
- boost asio 在linux下的proactor异步执行流程分析(一)
- Hadoop集群_MapReduce初级案例
- hadoop学习1---基础环境搭建与使用
- 光流法(Optical Flow)
- centos6.6开启防火墙
- Shell中逻辑判断
- bash 编程中循环语句用法
- 11安装CentOS7,附图 [原创]
- Shell中IFS用法
- HDevelop Language
- Shell中的${},##和%%的使用