(最短路 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 ...
随机推荐
- conductor Kitchensink示例
一个示例的厨房工作流程,演示了所有模式构造的使用. 定义 { "name": "kitchensink", "description": & ...
- 网页信息抓取 Jsoup的不足之处 httpunit
今天又遇到一个网页数据抓取的任务,给大家分享下. 说道网页信息抓取,相信Jsoup基本是首选的工具,完全的类JQuery操作,让人感觉很舒服.但是,今天我们就要说一说Jsoup的不足. 1.首先我们新 ...
- RedisTemplate Redis 操作
stringRedisTemplate.opsForValue().set("test", "100",60*10,TimeUnit.SECONDS);//向r ...
- 用NBU无法还原数据库到ASM磁盘
描述:用NBU无法还原数据库到ASM磁盘,却可以还原到数据库本地磁盘 错误提示: ORA-15025: could not open disk "/dev/mapper/DATA1" ...
- Leapin' Lizards(经典建图,最大流)
Leapin' Lizards http://acm.hdu.edu.cn/showproblem.php?pid=2732 Time Limit: 2000/1000 MS (Java/Others ...
- php5.3 延迟静态绑定 static关键字
//传统模式 --这段代码能很好工作,但大量的重复代码很烦人,不想为每个DomainObject子类都创建这段相同代码吧? /* abstract class DomainObject{} class ...
- HttpApplicationState与HttpApplication
HttpApplicationState 类的单个实例在客户端第一次从某个特定的 ASP.NET 应用程序虚拟目录中请求任何 URL 资源时创建.对于 Web 服务器上的每个 ASP.NET 应用程序 ...
- Django之ORM数据库
5.1 数据库的配置 1 django默认支持sqlite,mysql, oracle,postgresql数据库. <1> sqlite django默认使用sqlite的数据库 ...
- Linux dkpg命令
一.简介 dpkg 是Debian Package 的简写,是Debian系列系统下的一个软件安装.更新及移除工具. 二.常用指令 1.查询功能 查看软件包信息: dpkg -info xxx.deb ...
- Web开发者工具下载
登录微信公众号:https://mp.weixin.qq.com