【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 ...
随机推荐
- ”未能加载文件或程序集“Oracle.DataAccess”或它的某一个依赖项
引用:http://www.cnblogs.com/joey0210/archive/2012/09/29/2708420.html 上一篇文章说到了DLL引用问题,主要是说的程序中如果使用过了反射, ...
- E题hdu 1425 sort
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1425 sort Time Limit: 6000/1000 MS (Java/Others) M ...
- Perl6 Bailador框架(2):路径设置
use v6; use Bailador; =begin pod get表示是get发送 post表示是post发送 get/post 后面的 '/name' 表示是路径 => sub {} 是 ...
- python基础===利用PyCharm进行Python远程调试(转)
原文链接:利用PyCharm进行Python远程调试 背景描述 有时候Python应用的代码在本地开发环境运行十分正常,但是放到线上以后却出现了莫名其妙的异常,经过再三排查以后还是找不到问题原因,于是 ...
- 基于 Arduino 开发板,这款插座是可编程且开源的
基于 Arduino 开发板,这款插座是可编程且开源的 https://www.oschina.net/news/74861/open-source-socket https://github.com ...
- [转载]关于python字典类型最疯狂的表达方式
一个Python字典表达式谜题 让我们探究一下下面这个晦涩的python字典表达式,以找出在python解释器的中未知的内部到底发生了什么. # 一个python谜题:这是一个秘密 # 这个表达式计算 ...
- Name Disambiguation in AMiner-Clustering, Maintenance, and Human in the Loop
Name Disambiguation in AMiner: Clustering, Maintenance, and Human in the Loop paper:http://keg.cs.ts ...
- java - 线程1打印1-10,当线程打印到5后,线程2打印“hello”,然后线程1继续打印
public class T { private static int a =1;//1代表线程1 2线程2 public static void main(String[] args) { fina ...
- 0,null,undefined,[],{},'',false之间的关系
0与一些虚值的比较: 0与false 0==false true 0与'': =='' true 0与[]: ==[] true 0与NaN: 0==NaN false 0与undefined 0== ...
- 邂逅Sass和Compass之Sass篇
对于一个从后台转到前端的web开发者来说,最大的麻烦就是写CSS,了解CSS的人都知道,它可以开发网页样式,但是没法用它编程,感觉耦合性相当的高,如果想要方便以后维护,只能逐句修改甚至重写相当一部分的 ...