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. Java:网络编程之应用实例

    1.聊天 编写一个聊天程序,有收数据的部分和发数据的部分. 这两部分需要同时执行,那么就需要多线程技术. 一个线程控制发送. 一个线程控制接收. 因为收和发动作是不一致的,所以要定义两个run方法,而 ...

  2. log4j教程 1、概述

    log4j是一个用Java编写的可靠,快速和灵活的日志框架(API),它在Apache软件许可下发布.    Log4j已经被移植到了C,C++,C#,Perl,Python和Ruby等语言中.   ...

  3. HTML5游戏实战(1):50行代码实现正面跑酷游戏

    前段时间看到一个"熊来了"的HTML5跑酷游戏,它是一个典型的正面2D跑酷游戏,这里借用它来介绍一下用Gamebuilder+CanTK开发正面跑酷游戏的基本方法. CanTK(C ...

  4. 2017.3.31 spring mvc教程(三)拦截器

    学习的博客:http://elf8848.iteye.com/blog/875830/ 我项目中所用的版本:4.2.0.博客的时间比较早,11年的,学习的是Spring3 MVC.不知道版本上有没有变 ...

  5. Java的位运算

    左移位操作 左移位运算的符号为[<<],左移位运算符左面的操作元称作被移位数,右面的操作数称作移位量. 左移位运算是双目运算符,操作元必须是整型类型的数据,其移动过程是:[a <&l ...

  6. 从程序员到asp.net架构师转变[转]

    微软的DotNet开发绝对是属于那种入门容易提高难的技术.而要能够成为DotNet架构师没有三年或更长时间的编码积累基本上是不可能的.特别是在大型软件项目中,架构师是项目核心成员,承上启下,因此 RU ...

  7. java8 lambda 与 stream

    参见:https://www.bilibili.com/video/av14372754/?p=2

  8. 安装Linux centos 时编辑选项

    将第上一步选择编辑之后出来的文字修改为:>vmlinuz initrd=initrd.img linux dd quiet 这里注意了:网上很多文章都说这一步改成“>vmlinuz ini ...

  9. Notepad++搭配MinGW 配置编译运行C/C++

    1. Notepad++与Dev-Cpp都能编译运行, 环境变量的设置: 在PATH中加入"Dev-Cpp的MinGW64下的bin", 这是寻找gcc编译器的路径. 新建LIBR ...

  10. eclipse上的git命令使用浅析,搭建Maven项目

    eclipse上的git命令使用浅析 2016-03-31 14:44   关于eclipse上git的安装和建立代码仓库的文章比较多,但作为一个初识git的人更希望了解每个命令的作用. 当项目连接到 ...