Cow Contest
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 5989   Accepted: 3234

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组关系
每次关系输入A,B。表示A比B屌
思路:Flyod跑一发,然后判断是否这个人和其他人的关系都已经确定,如果都已经确定,那么就直接ans++就好了!
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 105
#define eps 1e-9
const int inf=0x7fffffff; //无限大
int g[maxn][maxn];
int main()
{
int n,m;
while(cin>>n>>m)
{
int a,b;
for(int i=;i<m;i++)
{
cin>>a>>b;
g[a][b]=;
}
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 ans=;
for(int i=;i<=n;i++)
{
int flag=;
for(int j=;j<=n;j++)
{
if(i==j)
continue;
if(g[i][j]==&&g[j][i]==)
{
flag=;
break;
}
}
if(flag)
ans++;
}
cout<<ans<<endl;
}
}
												

poj 3660 Cow Contest Flyod的更多相关文章

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

  2. POJ 3660 Cow Contest

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

  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——————【Floyd传递闭包】

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

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

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

  6. POJ 3660 Cow Contest(传递闭包floyed算法)

    Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5989   Accepted: 3234 Descr ...

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

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

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

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

  9. POJ 3660 Cow Contest (闭包传递)

    Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7690   Accepted: 4288 Descr ...

随机推荐

  1. Error: No resource found that matches the given name (at 'icon' with value '@mipmap/Icon')

    问题: error: Error: No resource found that matches the given name (at 'icon' with value '@mipmap/Icon' ...

  2. java基础67 JavaScript通过关系找节点、添加附件(网页知识)

    1.通过关系找节点(父子关系,兄弟关系) 1.1.常用方法 parentNode:获取当前元素的父节点.    childNodes:获取当前元素的所有下一级子元素    firstChild:获取当 ...

  3. apache代理配置https

    原文:https://mp.weixin.qq.com/s/Tw4UzX73Q7MSw3GJXnpN8A 微信小程序开发https设置 2017-04-06 格里菲斯 互联网工作者 微信官方规定小程序 ...

  4. R vs Python:载入包 import & library

    数据科学:R & Python 工作 & Kaggle机器学习比赛 可重复函数式编程 一.Python模块的载入 包 Package 模块 module import pandas a ...

  5. Rewrite HTTP to HTTPS in Nginx

    1.推荐配置 server { listen 80; server_name example1.com example2.com; return 301 https://$host$request_u ...

  6. (使用通过混淆+自己第三方保留成功混淆)AndroidStudio 混淆打包

    原文:https://blog.csdn.net/mazhidong/article/details/64820838 AndroidStudio中的项目可以用compile的形式引入github上的 ...

  7. bzoj 3144

    3144 思路: xxy: 代码: #include <cstdio> #include <cstring> #include <iostream> #includ ...

  8. day7 面向对象进阶

    面向对象高级语法部分 通过@staticmethod装饰器即可把其装饰的方法变为一个静态方法,什么是静态方法呢?其实不难理解,普通的方法,可以在实例化后直接调用,并且在方法里可以通过self.调用实例 ...

  9. python使用cookie登陆网页

    python2: Python 爬虫入门六之 Cookie 的使用 python3: Python3 网络爬虫 (六):Python3 使用 Cookie - 模拟登陆获取妹子联系方式 python ...

  10. C# 文件下载断点续传

    C# 文件下载断点续传的一个类 using System; using System.Collections.Generic; using System.Linq; using System.Text ...