(最短路 Floyd)Cow Contest --POJ--3660
链接:
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的更多相关文章
- Cow Contest POJ - 3660 (floyd 传递闭包)
N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we ...
- Cow Contest POJ - 3660 floyd传递闭包
#include<iostream> #include<cstring> using namespace std; ,INF=0x3f3f3f3f; int f[N][N]; ...
- Cow Contest POJ - 3660
题意 有n(1<=n<=100)个学生参加编程比赛. 给出m条实力信息.(1<=M<=4500) 其中每一条的格式为 A B (1<=A<=N,1<=B< ...
- POJ - 3660 Cow Contest 传递闭包floyed算法
Cow Contest POJ - 3660 :http://poj.org/problem?id=3660 参考:https://www.cnblogs.com/kuangbin/p/31408 ...
- POJ 3660—— Cow Contest——————【Floyd传递闭包】
Cow Contest Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- POJ 3660 Cow Contest 传递闭包+Floyd
原题链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- POJ 3660 Cow Contest (floyd求联通关系)
Cow Contest 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/H Description N (1 ≤ N ≤ 100) ...
- POJ 3660 Cow Contest(Floyd求传递闭包(可达矩阵))
Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16341 Accepted: 9146 Desc ...
- ACM: POJ 3660 Cow Contest - Floyd算法
链接 Cow Contest Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Descri ...
- poj 3660 Cow Contest(传递闭包 Floyd)
链接:poj 3660 题意:给定n头牛,以及某些牛之间的强弱关系.按强弱排序.求能确定名次的牛的数量 思路:对于某头牛,若比它强和比它弱的牛的数量为 n-1,则他的名次能够确定 #include&l ...
随机推荐
- 为什么要在linux命令前加上 ./
为什么要在linux命令前加上 ./ ? 简述 执行unix或linux中除了path系统变量外的目录下的命令都要加./. 修改用户的 .bash_profile,在 PATH一行最后加上 “:.” ...
- adb的一些常用的命令
如果在dos界面想要直接用adb的话,需要将anroidsdk安装目录下的tools和platform-tools以及加入到环境变量path中. 查看当前的设备(包括真机和模拟器):adb devic ...
- Ansible playbooks
Playbook是Ansible的配置,部署和编排语言. 他们可以描述您希望远程系统执行的策略,或一般IT流程中的一组步骤. 如果Ansible modules是您workshop的工具,则playb ...
- docker 操作
docker daemon 设置代理 http_proxy=109.105.4.17:8118 & systemctl start docker centos: Edit /etc/sysco ...
- centos7部署cacti
一.centos部署cacti 1. 关闭selinux. 2.fabric一键部署lamp 3. 设置mysql密码123456 1 mysql_secure_installation 4. 安装s ...
- IE6、IE7、Firefox中margin问题及input解决办法
margin不居中的问题 .div{ margin:10px;/*ff*/ *margin:15px;/*ie7*/ _margin:15px;/*ie6*/ 尺寸会变为正常的两倍,按道理应为5px ...
- python 的时间与日期
显示当前日期: import time print time.strftime('%Y-%m-%d %A %X %Z',time.localtime(time.time())) 或者 你也可以用: p ...
- 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 ...
- Java中的Filter
filter过滤器主要使用于前台向后台传递数据是的过滤操作.程度很简单就不说明了,直接给几个已经写好的代码: 一.使浏览器不缓存页面的过滤器 import javax.servlet.*; impor ...
- 在c#中设置Excel格式
生成excel的时候有时候需要设置单元格的一些属性,可以参考一下: range.NumberFormatLocal = "@"; //设置单元格格式为文本 ange.get_Ran ...