题意:奶牛拍电影,如果2个奶牛在同一场电影里演出,她们的合作度是1,如果ab合作,bc合作,ac的合作度为2,问哪一头牛到其他牛的合作度平均值最小再乘100

思路:floyd模板题

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
int f[][],a[]; int read(){
char ch=getchar();int f=,t=;
while (ch<''||ch>'') {if (ch=='-') f=-;ch=getchar();}
while (''<=ch&&ch<=''){t=t*+ch-'';ch=getchar();}
return t*f;
}
int main(){
int n,m;
n=read();m=read();
   memset(f,0x3f3f3f3f,sizeof f);for (int i=;i<=m;i++){
int cnt=read();
for (int j=;j<=cnt;j++)
a[j]=read();
for (int j=;j<=cnt;j++)
for (int k=;k<j;k++)
f[a[j]][a[k]]=f[a[k]][a[j]]=;
}
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
for (int k=;k<=n;k++)
f[j][k]=std::min(f[j][i]+f[i][k],f[j][k]);
int mn=0x7fffffff;
for (int i=;i<=n;i++){
int s=;
for (int j=;j<=n;j++)
if (i!=j) s+=f[i][j];
if (s<mn) mn=s;
}
mn*=;
mn/=(n-);
printf("%d\n",mn);
}

POJ 2139 Six Degrees of Cowvin Bacon (弗洛伊德最短路)的更多相关文章

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

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

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

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

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

  4. 任意两点间最短距离floyd-warshall ---- POJ 2139 Six Degrees of Cowvin Bacon

    floyd-warshall算法 通过dp思想 求任意两点之间最短距离 重复利用数组实现方式dist[i][j] i - j的最短距离 for(int k = 1; k <= N; k++) f ...

  5. POJ 2139 Six Degrees of Cowvin Bacon

    水题,Floyd. #include<cstdio> #include<cstring> #include<algorithm> using namespace s ...

  6. POJ 2139 Six Degrees of Cowvin Bacon (Floyd)

    题意:如果两头牛在同一部电影中出现过,那么这两头牛的度就为1, 如果这两头牛a,b没有在同一部电影中出现过,但a,b分别与c在同一部电影中出现过,那么a,b的度为2.以此类推,a与b之间有n头媒介牛, ...

  7. POJ:2139-Six Degrees of Cowvin Bacon

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

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

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

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

随机推荐

  1. 探索ReactNative应用

    本篇文章是我看AC2016腾讯前端技术交流大会后写的.写的不好,大家见谅啊. 一,什么是ReactNative? 简单来说就是可以用javascript来写APP了,而且性能还不错. 用JS写的话已经 ...

  2. Ubuntu 14.04 ThinkPad E431无线网卡驱动安装

    Ubuntu 14.04下安装无线网卡驱动. sudo apt-get install linux-headers-generic build-essential dkms  sudo apt-get ...

  3. 微信支付:curl 出错,错误码: 60

    在测试微信支付 - 模式二 - 扫码支付时,遇到如下错误: curl出错,错误码:60 这是因为在 WxPay.Api.php 文件中做了严格的 ssl 证书校验: curl_setopt($ch,C ...

  4. XCopy复制文件夹命令及参数详解以及xcopy拷贝目录并排除特定文件

    XCOPY是COPY的扩展,可以把指定的目录连文件和目录结构一并拷贝,但不能拷贝系统文件:使用时源盘符.源目标路径名.源文件名至少指定一个:选用/S时对源目录下及其子目录下的所有文件进行COPY.除非 ...

  5. ACdream 1157 Segments CDQ分治

    题目链接:https://vjudge.net/problem/ACdream-1157 题意: Problem Description 由3钟类型操作: 1)D L R(1 <= L < ...

  6. AspxGridView 表中的ASPxHyperLink不导出到excel

    在软件中 因为要连接到其他的页面所以类型转成了ASPxHyperLink,但是用官方的导出控件导出到excel之后,连接依旧保留着, 目的:去除导出来的连接 方法:把之前的ASPxHyperLink转 ...

  7. CMDB (后台管理) CURD 插件

    查 a. 基本实现 <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  8. POJ-2563

    Pick-up sticks Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 10364   Accepted: 3842 D ...

  9. LeetCode解题报告—— Word Search & Subsets II & Decode Ways

    1. Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be con ...

  10. poj 1426(同余搜索)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26926   Accepted: 111 ...