Cow Contest

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 10450   Accepted: 5841

Description

N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors.

The contest is conducted in several head-to-head rounds, each between two cows. If cow A has a greater skill level than cow B (1 ≤ A ≤ N; 1 ≤ B ≤ NA ≠ B), then cow A will always beat cow B.

Farmer John is trying to rank the cows by skill level. Given a list the results of M (1 ≤ M ≤ 4,500) two-cow rounds, determine the number of cows whose ranks can be precisely determined from the results. It is guaranteed that the results of the rounds will not be contradictory.

Input

* Line 1: Two space-separated integers: N and M
* Lines 2..M+1: Each line contains two space-separated integers that describe the competitors and results (the first integer, A, is the winner) of a single round of competition: A and B

Output

* Line 1: A single integer representing the number of cows whose ranks can be determined
 

Sample Input

5 5

4 3

4 2

3 2

1 2

2 5

Sample Output

2

//题意是 n 头牛 m 个牛的实力信息,给出 m 头牛的实力信息后,问多少的牛可以确定排名

//离散里面的传递闭包问题

//三重循环暴力即可

 #include <iostream>
#include <cstdio>
using namespace std;
int f[][],n,m; int main()
{
cin>>n>>m;
for (int i=;i<=m;i++)
{
int x,y;
cin >> x >> y;
f[x][y]=;
}
for (int k=;k<=n;k++)
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
if (f[i][k]+f[k][j]==)
f[i][j]=;
int ans=;
for (int i=;i<=n;i++)
{
int total=;
for (int j=;j<=n;j++)
if (f[i][j] || f[j][i]) total++;
if (total==n-) ans++;
}
cout << ans << endl;
}

Cow Contest(传递闭包)的更多相关文章

  1. POJ - 3660 Cow Contest 传递闭包floyed算法

    Cow Contest POJ - 3660 :http://poj.org/problem?id=3660   参考:https://www.cnblogs.com/kuangbin/p/31408 ...

  2. POJ 3660 Cow Contest 传递闭包+Floyd

    原题链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  3. POJ 3660 Cow Contest(传递闭包)

    N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we ...

  4. POJ 3660 Cow Contest. (传递闭包)【Floyd】

    <题目链接> 题目大意: 有n头牛, 给你m对关系(a, b)表示牛a能打败牛b, 求在给出的这些关系下, 能确定多少牛的排名. 解题分析: 首先,做这道题要明确,什么叫确定牛的排名.假设 ...

  5. POJ 3660 Cow Contest(传递闭包floyed算法)

    Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5989   Accepted: 3234 Descr ...

  6. POJ3660——Cow Contest(Floyd+传递闭包)

    Cow Contest DescriptionN (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a prog ...

  7. Bzoj 1612: [Usaco2008 Jan]Cow Contest奶牛的比赛 传递闭包,bitset

    1612: [Usaco2008 Jan]Cow Contest奶牛的比赛 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 891  Solved: 590 ...

  8. POJ 3660 Cow Contest(Floyd求传递闭包(可达矩阵))

    Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16341   Accepted: 9146 Desc ...

  9. POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包)

    POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包) Description N (1 ≤ N ...

随机推荐

  1. 联想Y430P CentOS 7.3 无线网络的配置

    # uname -a # 查看内核/操作系统/CPU信息的Linux系统信息命令 [root@www ~]# uname -a Linux www SMP Tue Nov :: UTC x86_64 ...

  2. MyEclipse导入Hibernate出现Path must include project and resource;/project name

    如图,在MyEclipse 2014以下版本中都没遇见这个问题. 在导入Hibernate框架的时候,可以说真的随缘,运气不好,明明配置全都没问题,还是连续几次失败,这个时候除了烧高香拜拜,也只能靠百 ...

  3. Android学习(十七)自定义View控件 TopBar

    一.创建自定义TopBar头部菜单条 实现步骤: 1.在values中添加attrs.xml文件,设置自定义属性. 2.添加Topbar类,继承RelativeLayout,实现具体功能. 3.添加到 ...

  4. Laravel之队列

    一.配置 队列配置文件存放在config/queue.php .在该文件中你将会找到框架自带的每一个队列驱动的连接配置,包括数据库.Beanstalkd. IronMQ. Amazon SQS. Re ...

  5. Python中的import和from import

    一.Python路径介绍 在python用import或者from...import来导入相应的模块. 模块其实就是一些函数和类的集合文件,它能实现一些相应的功能,当我们需要使用这些功能的时候,直接把 ...

  6. crm使用soap取消用户訪问记录权限

    //取消訪问权限 function demo() {     //操作记录的id     var targetId = "A8A46444-BA10-E411-8A04-00155D002F ...

  7. xpinyin-函数返回多个值-lambda匿名函数-列表生成式-三元表达式

    import xpinyinp=xpinyin.Pinyin() #实例化print(p.get_pinyin('小白','')) 函数返回多个值:1.函数如果返回多个值的话,它会把这几个值放到一个元 ...

  8. spring异常 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet

    spring异常 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet   情况 ...

  9. Java Learning Path(四) 方法篇

    Java Learning Path(四) 方法篇 Java作为一门编程语言,最好的学习方法就是写代码.当你学习一个类以后,你就可以自己写个简单的例子程序来运行一下,看看有什么结果,然后再多调用几个类 ...

  10. Smali语法:数据类型、方法和字段

    数据类型 dalvik字节码有两种类型,原始类型和引用类型.对象和数组是引用类型,其它都是原始类型. smali数据类型都是用一个字母表示,如果你熟悉Java的数据类型,你会发现表示smali数据类型 ...