POJ 2139 Six Degrees of Cowvin Bacon 最短路
来源:互联网 发布:古墓丽影8for mac 编辑:程序博客网 时间:2024/05/20 04:31
题目大意:有n头牛,如果两头牛同拍一部电影,这他们之间的距离为一,如果两头牛都和第三头牛拍过同一部电影,那么它们之间的距离经第三头牛传递就为2,,,求那一头牛与其它牛距离的平均值最小,把他乘一百输出。(求的时候,先扩大一百倍再求平均值)
#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> using namespace std; const int oo=1e9+1; int a[305][305]; void prepare() { for(int i=0;i<305;i++) for(int j=0;j<305;j++) if(i!=j) a[i][j]=a[j][i]=oo; } int b[106]; int main() { int n,m,x; while(~scanf("%d%d",&n,&m)) { prepare(); while(m--) { scanf("%d",&x); for(int i=0;i<x;i++) scanf("%d",&b[i]); for(int i=0;i<x;i++) for(int j=i+1;j<x;j++) a[b[i]][b[j]]=a[b[j]][b[i]]=1; } for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) a[i][j]=min(a[i][j],a[i][k]+a[k][j]); int minn=oo; for(int i=1;i<=n;i++) { int maxn=0; for(int j=1;j<=n;j++) maxn+=a[i][j]; minn=min(minn,100*maxn/(n-1)); } printf("%d\n",minn); } return 0; }
0 0
- poj 2139 Six Degrees of Cowvin Bacon 最短路
- POJ 2139-Six Degrees of Cowvin Bacon(最短路Floyd)
- Six Degrees of Cowvin Bacon (poj 2139 最短路Floyd)
- POJ 2139 Six Degrees of Cowvin Bacon(最短路)
- POJ 2139 Six Degrees of Cowvin Bacon 最短路
- POJ 2139 Six Degrees of Cowvin Bacon Floyd最短路
- POJ 2139 Six Degrees of Cowvin Bacon
- poj 2139--Six Degrees of Cowvin Bacon
- POJ-2139-Six Degrees of Cowvin Bacon
- POJ 2139 Six Degrees of Cowvin Bacon
- Six Degrees of Cowvin Bacon.(POJ-2139)
- POJ 2139 Six Degrees of Cowvin Bacon
- POJ 2139 Six Degrees of Cowvin Bacon
- poj 2139Six Degrees of Cowvin Bacon
- POJ 2139 Six Degrees of Cowvin Bacon
- POJ-2139 Six Degrees of Cowvin Bacon
- Six Degrees of Cowvin Bacon poj 2139
- POJ - 2139 Six Degrees of Cowvin Bacon(任意两点最短路,Floyd)
- DOM/BOM
- Arduino 舵机驱动板编程
- Excel VBA 中 Excel文件的操作
- 《利用Python进行数据分析》.(Wes McKinney).[PDF].pdf
- Codeforces Round #414, rated, Div. 1 + Div. 2 A. Bank Robbery
- POJ 2139 Six Degrees of Cowvin Bacon 最短路
- c语言题目集合
- HDU2222-AC自动机
- I。quadratic equation 山东第八届省赛
- LeetCode 26. Remove Duplicates from Sorted Array
- 国内用户使用Android Studio 提示帮助文档 一直显示:fetching documentation解决方案
- 开源|效果惊人!Cycle Gan瞬间让马变成斑马
- 机器学习:几种常见的学习方法
- HTML5本地存储之Web SQL Database