【Floyd】POJ2139 -Six Degrees of Cowvin Bacon
普通的Floyd了分分秒可以水过,结果在submit前删调试段落的时候把程序本体给删了吃了两个WA……
#include<iostream>
#include<cstring>
#include<cstdio>
const int INF=;
using namespace std;
const int MAXN=;
int len[MAXN][MAXN];
int f[MAXN][MAXN]; int n,m; int main()
{
scanf("%d%d",&n,&m);
for (int i=;i<n;i++)
{
for (int j=;j<n;j++) f[i][j]=INF;
f[i][i]=;
} for (int i=;i<m;i++)
{
int k;
int tempa[MAXN];
scanf("%d",&k);
for (int j=;j<k;j++)
{
scanf("%d",&tempa[j]);
tempa[j]--;
for (int l=;l<=j-;l++)
{
f[tempa[j]][tempa[l]]=;
f[tempa[l]][tempa[j]]=;
}
}
} for (int i=;i<n;i++)
for (int j=;j<n;j++)
for (int k=;k<n;k++)
f[i][j]=min(f[i][j],f[i][k]+f[k][j]); int ans=INF;
for (int i=;i<n;i++)
{
int sum=;
for (int j=;j<n;j++) sum+=f[i][j];
if (sum<ans) ans=sum;
}
cout<<(int)(ans*/(n-))<<endl;
return ;
}
【Floyd】POJ2139 -Six Degrees of Cowvin Bacon的更多相关文章
- POJ2139 Six Degrees of Cowvin Bacon [Floyd]
水题,随手敲过 一看就是最短路问题,a,b演同一场电影则他们的距离为1 默认全部两两原始距离无穷,到自身为0 输入全部数据处理后floyd 然后照它说的求平均分离度 再找最小的,×100取整输出 #i ...
- poj2139 Six Degrees of Cowvin Bacon
思路: floyd 实现: #include <iostream> #include <cstdio> #include <cstring> #include &l ...
- AOJ -0189 Convenient Location && poj 2139 Six Degrees of Cowvin Bacon (floyed求任意两点间的最短路)
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=78207 看懂题就好. 求某一办公室到其他办公室的最短距离. 多组输入,n表示 ...
- 【POJ - 2139】Six Degrees of Cowvin Bacon (Floyd算法求最短路)
Six Degrees of Cowvin Bacon Descriptions 数学课上,WNJXYK忽然发现人缘也是可以被量化的,我们用一个人到其他所有人的平均距离来量化计算. 在这里定义人与人的 ...
- POJ 2139 Six Degrees of Cowvin Bacon (floyd)
Six Degrees of Cowvin Bacon Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Ja ...
- POJ:2139-Six Degrees of Cowvin Bacon
传送门:http://poj.org/problem?id=2139 Six Degrees of Cowvin Bacon Time Limit: 1000MS Memory Limit: 6553 ...
- BZOJ1599 find the mincost route 【floyd】
题目链接 BZOJ1599 题解 最小环模板?周末了养生一下[逃] 解释一下原理 \(floyd\)算法每一轮求出以\([1,k]\)为中介点的最短路 我们对于一个环,考虑环上编号最大的点,在\(k\ ...
- 【Floyd】珍珠
[题目描述] 有n颗形状和大小都一致的珍珠,它们的重量都不相同.n为整数,所有的珍珠从1到n编号.你的任务是发现哪颗珍珠的重量刚好处于正中间,即在所有珍珠的重量中,该珍珠的重量列(n+1)/2位.下面 ...
- POJ2139--Six Degrees of Cowvin Bacon(最简单Floyd)
The cows have been making movies lately, so they are ready to play a variant of the famous game &quo ...
随机推荐
- React组件生命周期小结
React组件生命周期小结 下面所写的,只适合前端的React.(React也支持后端渲染,而且和前端有点小区别,不过我没用过.) 相关函数 简单地说,React Component通过其定义的几个函 ...
- solaris如何启动ssh服务
先查看一下ssh服务状态:# svcs或# svcs | grep sshonline Aug_07 svc:/network/ssh:default 如需要关闭ssh服务(关闭完可以 svcs | ...
- base--AuditResult
//参考base-4.0.2.jar public class AuditResult implements TimeReferable, Serializable //参考api-1.0.0.jar ...
- Lucene7.2.1系列(一)快速入门
系列文章: Lucene系列(一)快速入门 Lucene系列(二)luke使用及索引文档的基本操作 Lucene系列(三)查询及高亮 Lucene是什么? Lucene在维基百科的定义 Lucene是 ...
- perl6文件操作
use v6; #perl6中读取文件方法 #:r 只读, :w 只写, :rw 读写, :a 追加 my $fp = open 'filename.txt', :rw; for $fp.^metho ...
- 大公司开源网址[www]
https://github.com/blackberry https://github.com/CallForSanity?tab=repositories https://github.com/b ...
- Unknown character set: 'utf8mb4'
出现Unknown character set: 'utf8mb4'该错误是因为你的mysql-connector-java版本太高了,现在的mysql编码方式utf8mb4 然而老版本的却是utf ...
- ajax之深入解析(1)
AJAX = Asynchronous JavaScript and XML(异步的 JavaScript 和 XML).AJAX 是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术. AJ ...
- 获取分组后的TOP 1和TOP N记录
MySQL获取分组后的TOP 1和TOP N记录 有时会碰到一些需求,查询分组后的最大值,最小值所在的整行记录或者分组后的top n行的记录,在一些别的数据库可能有窗口函数可以方面的查出来,但是MyS ...
- C语言实现二叉排序树
程序以'#'结尾的二叉排序树. /*(双重指针 BSTree *T)问:数据结构中 二叉树建立结点为什么用 双重指针?详细解释下双重指针 答:指针的指针.因为树的结点要用指针描述.如果只用指针,作形参 ...