POJ 2139 Six Degrees of Cowvin Bacon
水题,Floyd。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int dis[][];
int f[];
int n,m; int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(i==j) dis[i][j]=;
else dis[i][j]=0x7fffffff;
}
}
for(int i=;i<=m;i++)
{
int x; scanf("%d",&x);
for(int j=;j<=x;j++) scanf("%d",&f[j]);
for(int j=;j<=x;j++)
for(int k=j+;k<=x;k++)
dis[f[j]][f[k]]=dis[f[k]][f[j]]=;
} for(int k=;k<=n;k++)
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)
if(dis[i][k]!=0x7fffffff&&dis[k][j]!=0x7fffffff&&dis[i][j]>dis[i][k]+dis[k][j] )
dis[i][j]=dis[i][k]+dis[k][j];
int ans=0x7fffffff;
for(int i=;i<=n;i++)
{
int sum=;
for(int j=;j<=n;j++) sum=sum+dis[i][j];
ans=min(ans,sum);
}
printf("%d\n",ans*/(n-));
return ;
}
POJ 2139 Six Degrees of Cowvin Bacon的更多相关文章
- 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 Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Ja ...
- <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 ...
- 任意两点间最短距离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 ...
- POJ 2139 Six Degrees of Cowvin Bacon (Floyd)
题意:如果两头牛在同一部电影中出现过,那么这两头牛的度就为1, 如果这两头牛a,b没有在同一部电影中出现过,但a,b分别与c在同一部电影中出现过,那么a,b的度为2.以此类推,a与b之间有n头媒介牛, ...
- POJ 2139 Six Degrees of Cowvin Bacon (弗洛伊德最短路)
题意:奶牛拍电影,如果2个奶牛在同一场电影里演出,她们的合作度是1,如果ab合作,bc合作,ac的合作度为2,问哪一头牛到其他牛的合作度平均值最小再乘100 思路:floyd模板题 #include& ...
- POJ:2139-Six Degrees of Cowvin Bacon
传送门:http://poj.org/problem?id=2139 Six Degrees of Cowvin Bacon Time Limit: 1000MS Memory Limit: 6553 ...
- 【POJ - 2139】Six Degrees of Cowvin Bacon (Floyd算法求最短路)
Six Degrees of Cowvin Bacon Descriptions 数学课上,WNJXYK忽然发现人缘也是可以被量化的,我们用一个人到其他所有人的平均距离来量化计算. 在这里定义人与人的 ...
- 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中to_date详细用法示例(oracle日期格式转换)
这篇文章主要介绍了oracle中to_date详细用法示例,包括期和字符转换函数用法.字符串和时间互转.求某天是星期几.两个日期间的天数.月份差等用法 TO_DATE格式(以时间:2007-11-02 ...
- Cormen — The Best Friend Of a Man
Cormen — The Best Friend Of a Man time limit per test 1 second memory limit per test 256 megabytes i ...
- Override/implements methods 如何添加
用过Eclipse 的ADT的都知道,要快速添加override或者implements方法,右键---Source---Override/Implements Method... 中文:右键---& ...
- Linux关闭防火墙,关闭Selinux
查看防火墙状态 iptables -L or service iptables status 临时性关闭防火墙 iptables -F or service iptables stop 永久性关闭防火 ...
- CodeForces 678B The Same Calendar
暴力.一年一年判断过去.如果某一年与输入的年份闰年性质相同,并且1月1日是星期几相同,那么输出. #include<cstdio> #include<cstring> #inc ...
- NYOJ 925 国王的烦恼
从最后一天开始往前加边. 同一天的边同时加到图上,加完之后检查集合数量是否和没加之前有变化. 有变化的话,答案就+1. #include<cstdio> #include <iost ...
- the.book.of.gimp.pdf文字不显示
逆天了,不是中文也不显示. https://bugs.freedesktop.org/show_bug.cgi?id=70529 说要升级libfreetype,可是已经是wheezy最新了,其他不稳 ...
- LayoutInflater 类的使用
转 http://yxwang0615.iteye.com/blog/1711147 一个Activity里如果直接用findViewById(),对应的是setConentView()的那个layo ...
- 用JavaScript 来将数字转换成字符。
背景: 一切嵌入式设备上面的信息,比如设备名称,设备时区是可以写入到设备上面的寄存器中的(一个寄存器两个字节,2*8 bit),比如 -1 ,写入到寄存器中为 2d31,然后可以通过一些进程将寄存器中 ...
- html常见标签使用
<body> <!--标题标签--> <h1></h1> <h2></h2> <h3></h3> < ...