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. appium window64安装教程

    查看虫师的博客 地址http://www.cnblogs.com/fnng/p/4540731.html 共四篇

  2. DB2中查询前十数据的sql

    select * from A fetch first 10 rows only

  3. 机器学习算法实践:朴素贝叶斯 (Naive Bayes)(转载)

    前言 上一篇<机器学习算法实践:决策树 (Decision Tree)>总结了决策树的实现,本文中我将一步步实现一个朴素贝叶斯分类器,并采用SMS垃圾短信语料库中的数据进行模型训练,对垃圾 ...

  4. 安装openstack 时 遇见的一些问题及解决方法!

    感谢朋友支持本博客,欢迎共同探讨交流.因为能力和时间有限,错误之处在所难免.欢迎指正! 假设转载.请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地 ...

  5. 倍福TwinCAT(贝福Beckhoff)基础教程3.1 TwinCAT如何编写简单的计算器

    把编写简单计算器作为入门的第一个范例程序,主要是因为比较简单,而且综合了HMI,数据类型,数据转换,PRG和FBD等功能块的混合等知识,个人认为还是比较适合用来快速上手的.由于是第一个范例,所以视频教 ...

  6. 内容提供器(ContentProvider)

    一.简介内容提供器(Content Provider)主要用于在不同的应用程序之间实现数据共享的功能,它提供了一套完整的机制,允许一个程序访问另一个程序中的数据,同时还能保证被访数据的安全性.目前,使 ...

  7. Linux非阻塞IO(八)使用epoll重新实现非阻塞的回射服务器

    本文无太多内容,主要是几个前面提到过的注意点: 一是epoll的fd需要重新装填.我们将tcp_connection_t的指针保存在数组中,所以我们以这个数组为依据,重新装填fd的监听事件. //重新 ...

  8. Django与SQL语言中——NULL与空字符串的区别

    SQL有指定空值的独特方式,它把空值叫做NULL. Null在数据库中表示 不知道的数据,主要有3种意思: 1)知道数据存在,但不知道具体值. 2)不知道数据是否存在. 3)数据不存在. 在SQL中, ...

  9. Linux 下Office 软件名称

    Linux 下Office 软件名称

  10. Shell脚本之:函数

    Shell 也支持函数.Shell函数必须先定义后使用. 函数的定义与调用 Shell 函数的定义格式如下: function_name () { list of commands [ return ...