水题,随手敲过

一看就是最短路问题,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]的更多相关文章

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

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

  2. 【Floyd】POJ2139 -Six Degrees of Cowvin Bacon

    普通的Floyd了分分秒可以水过,结果在submit前删调试段落的时候把程序本体给删了吃了两个WA…… #include<iostream> #include<cstring> ...

  3. poj2139 Six Degrees of Cowvin Bacon

    思路: floyd 实现: #include <iostream> #include <cstdio> #include <cstring> #include &l ...

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

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

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

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

  6. POJ:2139-Six Degrees of Cowvin Bacon

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

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

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

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

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

随机推荐

  1. Column count of mysql.user is wrong. Expected 43, found 42. Created with MySQL 50518, now running 50641. Please use mysql_upgrade to fix this error.

    出现问题: Column count of mysql.user is wrong. Expected 43, found 42. Created with MySQL 50518, now runn ...

  2. OGNL表达式中的#、%和$

    $是el表达式  % #是ognl表达式.  http://devilkirin.iteye.com/blog/427375 OGNL表达式非常强大-其中#.%.$这三个符号在OGNL表达式中经常出现 ...

  3. WIN10 无法访问2003 server共享

    With Windows 10 v1803 or Spring Creators update released I have decided to do a fresh installation o ...

  4. unity, water cube

    <纪念碑谷>里有一关开始是一个宝箱展开后里面有一个water cube,其中还有小鱼在游.如下截图: 因为我们知道<纪念碑谷>是unity做的,而现在正开始学unity,所以也 ...

  5. vsftp 无法启动,500 OOPS: bad bool value in config file for: anonymous_enable

    朋友的FTP启动不了,叫我帮他看,启动时出现以下错误信息: 500 OOPS: bad bool value in config file for: anonymous_enable 看似配置文件错误 ...

  6. LeetCode总结 -- 树的求和篇

    树的求和属于树的题目中比較常见的,由于能够有几种变体,灵活度比較高,也能够考察到对于树的数据结构和递归的理解. 一般来说这些题目就不用考虑非递归的解法了(尽管事实上道理是跟LeetCode总结 -- ...

  7. 【Android】13.2 使用自定义的CursorAdapter访问SQLite数据库

    分类:C#.Android.VS2015: 创建日期:2016-02-26 一.简介 SQliteDemo1的例子演示了SimpleCursorAdapter的用法,本节我们将使用用途更广的自定义的游 ...

  8. 线程相关函数(3)-pthread_detach()将某个线程设成分离态

    #include <pthread.h>int pthread_detach(pthread_t tid); pthread_t tid: 分离线程的tid返回值:成功返回0,失败返回错误 ...

  9. stl遍历map

    MapInfo* CGameConfig::getMapInfoById( int nId ) { for (map<int, MapInfo>::iterator it = m_mapM ...

  10. Android Studio 更新gradle插件

    今天更新了CentOS, 更新了java版本. 然后gradle跪了..... 不吐槽java版本的兼容性问题了.... 反正有他自己的理由.... 那么就更新gradle咯.... 下面是方法... ...