链接:

http://poj.org/problem?id=3660

思路:

1.  1->2->3==1->3

2.  记录每次的比赛人员

3.  每个人只能跟他序号不同的人比赛,因此他最多比了n-1场比赛

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<vector>
using namespace std; #define N 110
#define INF 0xfffffff int n, m;
int G[N][N], f[N][N], d[N]; void IN()
{
memset(f, false, sizeof(f));
memset(d, , sizeof(d));
for(int i=; i<=n; i++)
for(int j=; j<=i; j++)
{
G[i][j]=G[j][i]=INF;
}
} void Floyd()
{
for(int k=; k<=n; k++)
for(int i=; i<=n; i++)
for(int j=; j<=n; j++)
{
if(k!=i && k!=j && i!=j && !G[i][k] && !G[k][j])
{
if(!f[i][j])
{
G[i][j]=;
f[i][j]=;
d[i]++; d[j]++;
}
}
}
} int main()
{
while(scanf("%d%d", &n, &m)!=EOF)
{
int i, a, b; IN(); for(i=; i<m; i++)
{
scanf("%d%d", &a, &b);
G[a][b]=;
f[a][b]=;
d[a]++;d[b]++;
} Floyd(); int sum=; for(i=; i<=n; i++)
{
if(d[i]==n-)
sum++;
} printf("%d\n", sum);
}
return ;
}

(最短路 Floyd)Cow Contest --POJ--3660的更多相关文章

  1. Cow Contest POJ - 3660 (floyd 传递闭包)

    N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we ...

  2. Cow Contest POJ - 3660 floyd传递闭包

    #include<iostream> #include<cstring> using namespace std; ,INF=0x3f3f3f3f; int f[N][N]; ...

  3. Cow Contest POJ - 3660

    题意 有n(1<=n<=100)个学生参加编程比赛. 给出m条实力信息.(1<=M<=4500) 其中每一条的格式为 A B (1<=A<=N,1<=B< ...

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

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

  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

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

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

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

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

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

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

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

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

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

随机推荐

  1. Buffer I/O error on device sr0

    Buffer I/O error on device sr0, logical block 0 I check today some old CDs, some of them were from ’ ...

  2. iis配置asp.net常见验证失败问题解决方案

    很多朋友在用IIS6架网站的时候遇到不少问题,而这些问题有些在过去的IIS5里面就遇到过,有些是新出来的,俺忙活了一下午,做 了很多次试验,结合以前的排错经验,做出了这个总结,希望能给大家帮上忙:) ...

  3. 吴裕雄 实战PYTHON编程(9)

    import cv2 cv2.namedWindow("ShowImage1")cv2.namedWindow("ShowImage2")image1 = cv ...

  4. 序列比对之Biostrings包

    基本概念 Biostrings包很重要的3个功能是进行Pairwise sequence alignment 和Multiple sequence alignment及 Pattern finding ...

  5. spring boot 配置 freemarker

    1.springboot 中自带的页面渲染工具为thymeleaf 还有freemarker 这两种模板引擎 简单比较下两者不同, 1.1freemaker 优点 freemarker 不足:thym ...

  6. Python实现的常用排序方法

    1.冒泡排序,相邻位置比较大小,将比较大的(或小的)交换位置 def maopao(a):     for i in range(0,len(a)):         for j in range(0 ...

  7. scanf与printf

    scanf格式控制的完整格式: %     *     m     l或h     格式字符 ①格式字符与printf函数中的使用方式相同,以%d.%o.%x.%c.%s.%f.%e,无%u格式.%g ...

  8. 42. Trapping Rain Water (Array,stack; DP)

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  9. pairs

    pairs http://acm.hdu.edu.cn/showproblem.php?pid=5178 Time Limit: 2000/1000 MS (Java/Others)    Memor ...

  10. 鼠标经过的图片高亮显示,其余变暗效果[xyytit]

    初始代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...