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 ...
随机推荐
- HDU 2255 奔小康赚大钱 KM算法的简单解释
KM算法一般用来寻找二分图的最优匹配. 步骤: 1.初始化可行标杆 2.对新加入的点用匈牙利算法进行判断 3.若无法加入新编,修改可行标杆 4.重复2.3操作直到找到相等子图的完全匹配. 各步骤简述: ...
- How to write a probeContentType() and Usage?
Files.probeContentType() is an instance of FileTypeDetector class's abstract method String FileTypeD ...
- Jenkins email-ext邮件通知模板
http://blog.csdn.net/houyefeng/article/details/51344337 示例 以html格式发送送如下内容:邮件内容为项目名称.构建次数.触发原因.构建日志前1 ...
- Dom+2016/4/20
元素.parentNode父节点 offsetParent
- Python CGI编程和CGIHTTPServer
Python2.7 的CGIHTTPServer 可以作为一个简单的HTTP服务器,能够调用cgi脚本 1 在任意目录下创建一个特殊的目录 cgi-bin ,用于存放自己写的脚本(.py或.cgi) ...
- Web应用的组件化(二)——管控平台 #7
Web应用的组件化(二) 管控平台 在上一篇中我们提到了组件化的大致思路,这一篇主要讲述在这么做之后,我们需要哪些外围手段去管控整个开发过程.从各种角度看,面对较大规模前端开发团队,都有必要建立这么一 ...
- MySQL5.1升级5.6后,执行grant出错:ERROR 2013 (HY000): Lost connection to MySQL server during query【转载】
转载: MySQL5.5升级5.6后,执行grant出错:ERROR 2013 (HY000): Lost connection to -mysql教程-数据库-壹聚教程网http://www.111 ...
- Struts2 设置--Myelipse
1. Windows---preferrence---Myeclipse---Server----Tomcat 2. Windows---preferrence---Java---Installed ...
- jquery判断节点是否存在
if($('.onloadMore').length>0){ return '节点存在'; }else{ return '节点不存在'; }
- ecb, 找不到button
我问了一下,http://stackoverflow.com/questions/17667554/when-configuring-ecb-i-cant-found-button-save-for- ...