题目链接

 /*
Name:nyoj-211-Cow Contest
Copyright:
Author:
Date: 2018/4/27 21:02:06
Description:
floyd算法
大佬的惊奇思路
*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; const int MAXN = ;
const int INF = 0x3f3f3f3f;
int N, g[MAXN][MAXN], M; void floyd() {
for (int k=; k<=N; k++) {
for (int i=; i<=N; i++) {
for (int j=; j<=N; j++) {
if (g[i][k] && g[k][j])
g[i][j] = ;//有关系
}
}
}
}
int main()
{
while (cin>>N>>M, N+M) {
memset(g, , sizeof(g));
for (int i=; i<M; i++) {
int x, y;
cin>>x>>y;
g[x][y] = ;
}
floyd();
int i, j, ans=;
for (i=; i<=N; i++) {
for (j=; j<=N; j++) {
if (i==j) continue;
if (g[i][j] == && g[j][i] == ) break;//和其他牛中的一头没有关系就不能确定排名
}
if (j > N) ans++;
}
cout<<ans<<endl;
}
return ;
}

nyoj-211-Cow Contest(floyd算法)的更多相关文章

  1. nyoj 211——Cow Contest——————【floyd传递闭包】

    Cow Contest 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 N (1 ≤ N ≤ 100) cows, conveniently numbered 1.. ...

  2. ACM: POJ 3660 Cow Contest - Floyd算法

    链接 Cow Contest Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Descri ...

  3. NYOJ 211 Cow Contest (弗洛伊德+传递闭包 )

    title: Cow Contest 弗洛伊德+传递闭包 nyoj211 tags: [弗洛伊德,传递闭包] 题目链接 描述 N (1 ≤ N ≤ 100) cows, conveniently nu ...

  4. nyoj 211 Cow Contest

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=211 思路:我的思路是对每一个点,向上广搜,向下广搜,看总共能不能搜到n-1个结点,能,表 ...

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

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

  6. POJ3660 Cow Contest —— Floyd 传递闭包

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

  7. POJ3660 Cow Contest floyd传递闭包

    Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming con ...

  8. POJ-3660 Cow Contest Floyd传递闭包的应用

    题目链接:https://cn.vjudge.net/problem/POJ-3660 题意 有n头牛,每头牛都有一定的能力值,能力值高的牛一定可以打败能力值低的牛 现给出几头牛的能力值相对高低 问在 ...

  9. POJ 3660 Cow Contest (Floyd)

    题目链接:http://poj.org/problem?id=3660 题意是给你n头牛,给你m条关系,每条关系是a牛比b牛厉害,问可以确定多少头牛的排名. 要是a比b厉害,a到b上就建一条有向边.. ...

随机推荐

  1. boost之字符串与文本处理

    C++标准库中字符串转数值使用函数atoi(),数值转字符串使用printf系列函数. boost中使用转换函数操作符lexical_cast<>进行转换,实际上是模板函数.自定义类型,要 ...

  2. Java栈和堆的区别

    一.栈空间 1.栈空间存储数据效率高 2.栈中的数据是按“先进后出”的方式管理 3.栈空间存储空间比较小,不能存放大量的数据 4.JVM将基本类型的数据存放在栈空间 帮助理解 1.“客栈” 能提供很多 ...

  3. Educational Codeforces Round 29(6/7)

    1.Quasi-palindrome 题意:问一个字符串(你可以添加前导‘0’或不添加)是否是回文串 思路:将给定的字符串的前缀‘0’和后缀‘0’都去掉,然后看其是否为回文串 #include< ...

  4. mongodb php 支持

    http://bbs.csdn.net/topics/391931404?page=1 windows下为php7.0.4安装目前官方版本对应的最新的php_mongodb.dll扩展,该扩展版本为1 ...

  5. Linux基础四---系统监控&硬盘分区

    ---恢复内容开始--- 一系统分区 1.top [参数] -b 批处理 -c 显示命令完全模式 -I 忽略失效过程 -s 保密模式 -S 累积模式 -i<时间> 设置间隔时间 -u< ...

  6. html5-entities.js消失问题

    今天用nuxt做项目时,启动npm run dev,项目正常启动, 可过一会儿再试图启动时却报错: * ./libhtml5-entities.js in ./~/html-entities/inde ...

  7. 三 ip dns等配置

    一IP.端口.协议基本概念 ip的简单概念 互联网上的计算机,都会有一个唯一的32位的地址,ip地址 我们访问服务器,就必须通过ip地址 局域网里也有预留的ip地址  192/10/172.居于王的i ...

  8. 20145239杜文超《网络攻防》- MSF基础应用

    20145239杜文超<网络攻防>- MSF基础应用 基础问题回答 1.用自己的话解释什么是exploit,payload,encode? exploit:实现攻击行为的主体,但没有载荷只 ...

  9. Yii技巧大全(摘录)

    Yii技巧大全(摘录) db组件 'schemaCachingDuration'=>3600, 为什么不起做用? 需要开缓存 如何在页面下边显示sql的查询时间 在log组件的routes中加入 ...

  10. Nginx错误日志配置信息详解

    Nginx的错误日志可以配置在Main区块,也可以配置在虚拟主机区块中.Nginx软件会把自身运行的故障信息及用户访问的日志信息记录到指定的日志文件里,是我们调试Nginx服务的重要参考. error ...