(最短路 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 ...
随机推荐
- 【转载】Apache Jena TDB CRUD operations
Apache Jena TDB CRUD operations June 11, 2015 by maltesander http://tutorial-academy.com/apache-jena ...
- Technology, globalisation and the squeeze on good jobs
Technology, globalisation and the squeeze on good jobs技术与全球化冲击好工作“Highest stock market EVER! Jobs ar ...
- 【完结汇总】iKcamp出品基于Koa2搭建Node.js实战共十一堂课(含视频)
- Hibernate迫切左外连接和迫切内连接
•迫切左外连接: •LEFT JOIN FETCH 关键字表示迫切左外连接检索策略. –list() 方法返回的集合中存放实体对象的引用, 每个 Department 对象关联的 Employee ...
- sessionpage1
session1 <%@page import="java.text.SimpleDateFormat"%> <%@ page language="ja ...
- Linux下php5.3.3安装mcrypt扩展
具体操作: 一.下载软件包 1.下载php(版本要与系统安装的一致) http://pan.baidu.com/s/1mifTbfE 2.下载libmcrypt(安装mcrypt需要此软件包) htt ...
- Bean Validation技术实现对Javabean的校验
概述:在java开发时,由于分层的原因(表现层-控制层-业务层-数据持久层),有时候需要对传入的Javabean进行校验,如果过多的校验会导致比较繁琐,做重复的工作,下面将介绍Bean Validat ...
- 如何快速实现一个command
新建一个类,实现icoomand接口 定义一个委托,为测试方便,先不考虑CanExecute的情况. 越简单越好. 代码如下: public class ExitHandler : ICommand ...
- IIS中的MIME类型设置
https://www.cnblogs.com/David-Young/p/5323949.html
- 前端知识--------HTML内容
HTML介绍 1.web服务本质 import socket sk = socket.socket() sk.bind(('127.o.o.1',8080)) sk.listen() while 1: ...