思路:

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. Java中需要了解的点

    1.32位jvm.64位区别? 2.

  2. Delphi通过Get获取来自PHP的返回值

    Delphi代码 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Contro ...

  3. HDU3667 Transportation —— 最小费用流(费用与流量平方成正比)

    题目链接:https://vjudge.net/problem/HDU-3667 Transportation Time Limit: 2000/1000 MS (Java/Others)    Me ...

  4. OpenCV——PS滤镜算法之 Ellipsoid (凹陷)

    // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...

  5. I.MX6 U-boot imxotp MAC address 写入

    /***************************************************************************** * I.MX6 U-boot imxotp ...

  6. MyBatis缓存设计

    和大多数ORM框架一样,为了尽可能减少数据库的访问,MyBatis设计支持缓存功能.设计上通过Cache接口提供SPI(服务提供接口),可以让第三方缓存提供具体的缓存实现,比如使用ehcache.Re ...

  7. codeforces round 421 div2 补题 CF 820 A-E

    A Mister B and Book Reading  O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef lon ...

  8. Allure生成测试报告

    Allure 使用 安装 adapter 如果要在 pytest 中使用 Allure,需要使用一个 Adaptor Allure Pytest Adaptor 安装 pytest-allure-ad ...

  9. ASP.NET Core:Pages

    ylbtech-ASP.NET Core:Pages 1.返回顶部 1._Layout.cshtm <!DOCTYPE html> <html> <head> &l ...

  10. 修改CentOS系统的默认启动级别

    ======修改CentOS系统的默认启动级别====== 现在的Linux系统安装完后就运行在第5个级别,即系统启动后直接进入图形界面,而不用在字符模式下登录后用startx或者xinit来起动图形 ...