题目链接:http://poj.org/problem?id=3660

题意是给你n头牛,给你m条关系,每条关系是a牛比b牛厉害,问可以确定多少头牛的排名。

要是a比b厉害,a到b上就建一条有向边......这样建好之后,如果比a牛厉害的牛都能达到a牛,而a牛能到达比a牛差的牛的话,牛的头数又恰好是n-1头,那么a牛的排名则是确定的。

所以用Flody比较方便,要是i到k能到达,k到j能到达,那么i到j就能到达,i就比j厉害。

 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = ;
bool cost[MAXN][MAXN]; void init() {
memset(cost , false , sizeof(cost));
} int main()
{
int n , m , u , v;
while(cin >> n >> m) {
init();
while(m--) {
cin >> u >> v;
cost[u][v] = true;
}
for(int k = ; k <= n ; k++) {
for(int j = ; j <= n ; j++) {
for(int i = ; i <= n ; i++) {
if(cost[i][k] && cost[k][j])
cost[i][j] = true;
}
}
}
int cont , res = ;
for(int i = ; i <= n ; i++) {
cont = ;
for(int j = ; j <= n ; j++) {
if(cost[i][j] != cost[j][i])
cont += ;
}
if(cont == n - )
res++;
}
cout << res << endl;
}
}

POJ 3660 Cow Contest (Floyd)的更多相关文章

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

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

  2. 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 ...

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

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

  4. POJ 3660 Cow Contest

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

  5. POJ 3660—— Cow Contest——————【Floyd传递闭包】

    Cow Contest Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit  ...

  6. POJ 3660 Cow Contest (floyd求联通关系)

    Cow Contest 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/H Description N (1 ≤ N ≤ 100) ...

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

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

  8. poj 3660 Cow Contest(传递闭包 Floyd)

    链接:poj 3660 题意:给定n头牛,以及某些牛之间的强弱关系.按强弱排序.求能确定名次的牛的数量 思路:对于某头牛,若比它强和比它弱的牛的数量为 n-1,则他的名次能够确定 #include&l ...

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

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

随机推荐

  1. UVa 10892 (GCD) LCM Cardinality

    我一直相信这道题有十分巧妙的解法的,去搜了好多题解发现有的太过玄妙不能领会. 最简单的就是枚举n的所有约数,然后二重循环找lcm(a, b) = n的个数 #include <cstdio> ...

  2. Java知识点:Object类

    toString()方法 原始实现: public String toString() { return getClass().getName() + "@" + Integer. ...

  3. memcache的最佳实践方案。

    基本问题 1.memcached的基本设置 1)启动Memcache的服务器端 # /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 ...

  4. Darwin Streaming Server 安裝操作備忘

    Darwin Streaming Server 安裝操作 Darwin Streaming Server是蘋果公司推出的開放源碼.跨平台多媒體串流伺服器, 提供音樂 (mp3) 與影音 (3gp.mp ...

  5. 当ASP.NET MVC模型验证遇上CKEditor

    项目需要,使用到了CKEditor编辑器.这是个很不错的富文本编辑器,但是当它绑定的字段需要进行模型验证的时候,却会出现验证失效的问题.因此本文旨在记录这个问题和给出解决办法.以下以Validatio ...

  6. Delphi 自带的那个 Hand 光标很难看?没关系,一行代码解决问题:

    Delphi 自带的那个 Hand 光标很难看?没关系,一行代码解决问题: Screen.Cursors[crHandPoint] := LoadCursor(0, IDC_HAND);放在主窗体 O ...

  7. linux中waitpid及wait的用法

    wait(等待子进程中断或结束) 表头文件      #include<sys/types.h>      #include<sys/wait.h> 定义函数 pid_t wa ...

  8. How to Calculate difference between two dates in C# z

    Do you need to find the difference in number of days, hours or even minute between the two date rang ...

  9. ISAPI在IIS7上的配置

    主要介绍ISAPI的作用.ISAPI在IIS7上的配置.开发ISAPI的基本内容及使用VS 2008配置ISAPI DLL开发项目. 一.ISAPI介绍 缩写词=Internet Server App ...

  10. Cloudera的安装

    To enable these parts of the tutorial, choose one of the following options: To use Cloudera Express ...