题目链接

 /*
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. 3.3 使用STC89C52控制MC20通过GPRS远程发送数据

    需要准备的硬件 MC20开发板 1个 https://item.taobao.com/item.htm?id=562661881042 GSM/GPRS天线 1根 https://item.taoba ...

  2. 流量监控系统---storm集群配置

    1.集群部署的基本流程 集群部署的流程:下载安装包.解压安装包.修改配置文件.分发安装包.启动集群 注意: 所有的集群上都需要配置hosts vi  /etc/hosts 192.168.223.20 ...

  3. 41和为S的连续正数序列

    题目描述 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100.但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数).没多久,他 ...

  4. iOS git 托管代码 常用几个操作

    学习 git 切换分支 1  从远程下载一个分支develop(本地没有的) (1) git fetch origin develop (2) git checkout develop (默认 分支切 ...

  5. 纯代码编写qt登录界面(转)

    1. 新建Qt Widgets Application,项目名称为login1,在类信息页面保持类名和基类为MainWindow和QMainWindow不变,取消选择创建界面选项,如下图所示.     ...

  6. android camera jni调用

    http://www.mamicode.com/info-detail-1002139.html how to compile  library of native camera for androi ...

  7. Redux API之bindActionCreators

    bindActionCreators(actionCreators,dispatch) 把 action creators 转成拥有同名 keys 的对象,但使用 dispatch 把每个 actio ...

  8. Eclipse SVN插件设置

    项目开发中,开发人员用SVN来管理代码,在和服务器同步时,需要避免上传不必要的一些编译文件,如.class,.log,target等文件,这里需要设置同步选项. 打开Eclipse ---> W ...

  9. phpMyAdmin中config.inc.php设置密码和修改密码的方法

    phpMyAdmin有3种授权模式: 1. cookie: 显示一个web登录页面,输入mysql的用户名和密码,然后进入管理界面. $cfg['Servers'][$i]['auth_type'] ...

  10. Java 关于final那些事

    先说结论:对于引用类型的变量,Java本身会创建两个东西,一个是对象本身,另一个是记录对象地址的一个int值,将引用类型的对象声明为final实际上是固定记录地址的那个int的值不能改变,如果通过某种 ...