POJ2139 Six Degrees of Cowvin Bacon [Floyd]
水题,随手敲过
一看就是最短路问题,a,b演同一场电影则他们的距离为1
默认全部两两原始距离无穷,到自身为0
输入全部数据处理后floyd
然后照它说的求平均分离度
再找最小的,×100取整输出
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int cownum,filmnum;
int film[11111][333];
int g[333][333];
int inf=(1<<30)-1;
int main()
{
scanf("%d%d",&cownum,&filmnum);
for(int i=1;i<=cownum;i++)
{
for(int j=1;j<=cownum;j++)
{
if(i==j)
g[i][j]=0;
else
g[i][j]=inf;
}
}
for(int i=1;i<=filmnum;i++)
{
int everyfilmcownum;
scanf("%d",&everyfilmcownum);
for(int j=1;j<=everyfilmcownum;j++)
{
scanf("%d",&film[i][j]);
}
for(int ii=1;ii<=everyfilmcownum;ii++)
{
for(int jj=1;jj<=everyfilmcownum;jj++)
{
int a=film[i][ii];
int b=film[i][jj];
if(ii!=jj)
g[a][b]=1;
}
}
}
for(int i=1;i<=cownum;i++)
for(int j=1;j<=cownum;j++)
for(int k=1;k<=cownum;k++)
if(g[i][j]>g[i][k]+g[k][j])
g[i][j]=g[i][k]+g[k][j];
double minn=9999999;
for(int i=1;i<=cownum;i++)
{
double res=0;
for(int j=1;j<=cownum;j++)
{
res+=g[i][j];
}
res/=cownum-1;
minn=min(minn,res);
}
printf("%d\n",int(minn*100));
}
POJ2139 Six Degrees of Cowvin Bacon [Floyd]的更多相关文章
- POJ 2139 Six Degrees of Cowvin Bacon (floyd)
Six Degrees of Cowvin Bacon Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Ja ...
- 【Floyd】POJ2139 -Six Degrees of Cowvin Bacon
普通的Floyd了分分秒可以水过,结果在submit前删调试段落的时候把程序本体给删了吃了两个WA…… #include<iostream> #include<cstring> ...
- poj2139 Six Degrees of Cowvin Bacon
思路: floyd 实现: #include <iostream> #include <cstdio> #include <cstring> #include &l ...
- 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 Descriptions 数学课上,WNJXYK忽然发现人缘也是可以被量化的,我们用一个人到其他所有人的平均距离来量化计算. 在这里定义人与人的 ...
- POJ:2139-Six Degrees of Cowvin Bacon
传送门:http://poj.org/problem?id=2139 Six Degrees of Cowvin Bacon Time Limit: 1000MS Memory Limit: 6553 ...
- 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 ...
- <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 ...
- POJ 2139 Six Degrees of Cowvin Bacon (Floyd)
题意:如果两头牛在同一部电影中出现过,那么这两头牛的度就为1, 如果这两头牛a,b没有在同一部电影中出现过,但a,b分别与c在同一部电影中出现过,那么a,b的度为2.以此类推,a与b之间有n头媒介牛, ...
随机推荐
- HQL的select new map ···语法
通常hibernate查询出的结果集是类似于 List<T> 或 List<Object[]> 的类型 类似于下面这个方法 public List<SfJmsfT> ...
- CDH quick start VM 中运行wordcount例子
需要注意的事情: 1. 对于wordcount1.0 ,按照http://www.cloudera.com/content/cloudera/en/documentation/HadoopTutori ...
- RBAC权限管理(转)
RBAC(Role-Based Access Control,基于角色的访问控制),就是用户通过角色与权限进行关联.简单地说,一个用户拥有若干角色,每一个角色拥有若干权限.这样,就构造成“用户-角色- ...
- xaf 修改主页logo
https://documentation.devexpress.com/#Xaf/CustomDocument3156
- sql中一列拆成两列
declare @table table (name nvarchar(4))insert into @tableselect '张三' union allselect '李四' union alls ...
- unity, yield return new WaitForSeconds(waitTime) 在 Time.timeScale=0下卡死
例如下面代码: IEnumerator f(){ Time.timeScale = 0; float waitTime=2; yield return new WaitForSeconds (wait ...
- ngRoute 和 ui.router 的使用方法和区别
在单页面应用中要把各个分散的视图给组织起来是通过路由机制来实现的.本文主要对 AngularJS 原生的 ngRoute 路由模块和第三方路由模块 ui.router 的用法进行简单介绍,并做一个对比 ...
- JCO 自定义DestinationDataProvider
要让JAVA程序能访问SAP系统,一般通过SAP JCO接口进行通讯,在获取到SAP的连接时需求提供一些连接参数,这些参数在最新的 JCO 3.0 中需要被保存到一个带有扩展名.jcoDestinat ...
- 0061 Spring MVC的数据格式化--Formatter--FormatterRegistrar--@DateTimeFormat--@NumberFormat
Converter只完成了数据类型的转换,却不负责输入输出数据的格式化工作,日期时间.货币等虽都以字符串形式存在,却有不同的格式. Spring格式化框架要解决的问题是:从格式化的数据中获取真正的数据 ...
- php html 转义
html_entity_decode($string);htmlentities($string);htmlspecialchars($string);htmlspecialchars_decode( ...