思路:

floyd

实现:

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std; int a[][], n, m, k;
const int INF = 0x3f3f3f3f;
int main()
{
memset(a, 0x3f, sizeof(a));
cin >> n >> m;
for (int i = ; i < m; i++)
{
vector<int> l;
int tmp;
cin >> k;
for (int j = ; j < k; j++)
{
cin >> tmp;
l.push_back(tmp);
}
for (int p = ; p < k; p++)
{
for (int q = ; q < k; q++)
{
a[l[p]][l[q]] = p == q ? : ;
}
}
}
for (int k = ; k <= n; k++)
{
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
if (a[i][k] + a[k][j] < a[i][j])
{
a[i][j] = a[i][k] + a[k][j];
}
}
}
}
double __ = INF;
for (int j = ; j <= n; j++)
{
int sum = ;
for (int k = ; k <= n; k++)
{
sum += a[j][k];
}
double ans = sum * 1.0 / (n - );
__ = min(ans, __);
}
cout << (int)(__ * ) << endl;
return ;
}

poj2139 Six Degrees of Cowvin Bacon的更多相关文章

  1. POJ2139 Six Degrees of Cowvin Bacon [Floyd]

    水题,随手敲过 一看就是最短路问题,a,b演同一场电影则他们的距离为1 默认全部两两原始距离无穷,到自身为0 输入全部数据处理后floyd 然后照它说的求平均分离度 再找最小的,×100取整输出 #i ...

  2. 【Floyd】POJ2139 -Six Degrees of Cowvin Bacon

    普通的Floyd了分分秒可以水过,结果在submit前删调试段落的时候把程序本体给删了吃了两个WA…… #include<iostream> #include<cstring> ...

  3. AOJ -0189 Convenient Location && poj 2139 Six Degrees of Cowvin Bacon (floyed求任意两点间的最短路)

    http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=78207 看懂题就好. 求某一办公室到其他办公室的最短距离. 多组输入,n表示 ...

  4. 【POJ - 2139】Six Degrees of Cowvin Bacon (Floyd算法求最短路)

    Six Degrees of Cowvin Bacon Descriptions 数学课上,WNJXYK忽然发现人缘也是可以被量化的,我们用一个人到其他所有人的平均距离来量化计算. 在这里定义人与人的 ...

  5. POJ 2139 Six Degrees of Cowvin Bacon (floyd)

    Six Degrees of Cowvin Bacon Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Ja ...

  6. POJ:2139-Six Degrees of Cowvin Bacon

    传送门:http://poj.org/problem?id=2139 Six Degrees of Cowvin Bacon Time Limit: 1000MS Memory Limit: 6553 ...

  7. <poj - 2139> Six Degrees of Cowvin Bacon 最短路径问题 the cow have been making movies

    本题链接:http://poj.org/problem?id=2139 Description:     The cows have been making movies lately, so the ...

  8. 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 ...

  9. POJ-2139 Six Degrees of Cowvin Bacon---Floyd

    题目链接: https://vjudge.net/problem/POJ-2139 题目大意: 给定一些牛的关系,他们之间的距离为1. 然后求当前这只牛到每只牛的最短路的和,除以 n - 1只牛的最大 ...

随机推荐

  1. get all sites under IIS

    https://stackoverflow.com/questions/2555668/how-to-programmatically-get-sites-list-and-virtual-dirs- ...

  2. kentico检查当前授权用户,是否为admin角色

    https://docs.kentico.com/k11/custom-development/user-internals-and-api/checking-permissions-using-th ...

  3. html5--6-4 CSS选择器

    html5--6-4 CSS选择器 实例 学习要点 掌握常用的CSS选择器 了解不太常用的CSS选择器 什么是选择器 当我们定义一条样式时候,这条样式会作用于网页当中的某些元素,所谓选择器就是样式作用 ...

  4. 「LuoguP3191」 [HNOI2007]紧急疏散EVACUATE(最大流

    Description 发生了火警,所有人员需要紧急疏散!假设每个房间是一个N M的矩形区域.每个格子如果是’.’,那么表示这是一块空地:如果是’X’,那么表示这是一面墙,如果是’D’,那么表示这是一 ...

  5. Ordered Fractions

    链接 分析:遍历一下,求个gcd即可,最后按照ans排序并去重 /* PROB:frac1 ID:wanghan LANG:C++ */ #include "iostream" # ...

  6. apple-touch-startup-image 制作iphone web应用程序的启动画面

    为ipad制作web应用程序的启动画面时发现个问题,只能显示竖屏图,横屏图出不来,如下: 首先页面头部里要加入(这个是APP启动画面图片,如果不设置,启动画面就是白屏,图片像素就是手机全屏的像素) & ...

  7. 6-12 SVM小结

    介绍了SVM的概念以及如何利用SVM进行一个身高体重的训练和预测.如果类别比较简单的话,那么在二维空间上它有可能就是一条直线.如果类别比较复杂,那么投影到高维空间上它就是一个超平面.所以SVM的本质它 ...

  8. Android Layout XML属性研究--android:layout_marginBottom (转载)

    转自:http://blog.csdn.net/yanfangjin/article/details/7393023 在如下的xml配置文件中,起初对于android:layout_marginBot ...

  9. Playground Tutorial

    In this step by step tutorial we'll walk through setting up a business network, defining our assets, ...

  10. E20180418-hm

    utility n. [计]工具; 公用事业; 功用,效用; 有用的物体或器械; 公用事业公司; identity n. 身份; identifier  n. 识别符; 检验人,标识符; 鉴别器; 编 ...