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

 #include<iostream>
#include<cstring>
#include<cstdio>
const int INF=;
using namespace std;
const int MAXN=;
int len[MAXN][MAXN];
int f[MAXN][MAXN]; int n,m; int main()
{
scanf("%d%d",&n,&m);
for (int i=;i<n;i++)
{
for (int j=;j<n;j++) f[i][j]=INF;
f[i][i]=;
} for (int i=;i<m;i++)
{
int k;
int tempa[MAXN];
scanf("%d",&k);
for (int j=;j<k;j++)
{
scanf("%d",&tempa[j]);
tempa[j]--;
for (int l=;l<=j-;l++)
{
f[tempa[j]][tempa[l]]=;
f[tempa[l]][tempa[j]]=;
}
}
} for (int i=;i<n;i++)
for (int j=;j<n;j++)
for (int k=;k<n;k++)
f[i][j]=min(f[i][j],f[i][k]+f[k][j]); int ans=INF;
for (int i=;i<n;i++)
{
int sum=;
for (int j=;j<n;j++) sum+=f[i][j];
if (sum<ans) ans=sum;
}
cout<<(int)(ans*/(n-))<<endl;
return ;
}

【Floyd】POJ2139 -Six Degrees of Cowvin Bacon的更多相关文章

  1. POJ2139 Six Degrees of Cowvin Bacon [Floyd]

    水题,随手敲过 一看就是最短路问题,a,b演同一场电影则他们的距离为1 默认全部两两原始距离无穷,到自身为0 输入全部数据处理后floyd 然后照它说的求平均分离度 再找最小的,×100取整输出 #i ...

  2. poj2139 Six Degrees of Cowvin Bacon

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

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

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

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

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

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

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

  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. BZOJ1599 find the mincost route 【floyd】

    题目链接 BZOJ1599 题解 最小环模板?周末了养生一下[逃] 解释一下原理 \(floyd\)算法每一轮求出以\([1,k]\)为中介点的最短路 我们对于一个环,考虑环上编号最大的点,在\(k\ ...

  8. 【Floyd】珍珠

    [题目描述] 有n颗形状和大小都一致的珍珠,它们的重量都不相同.n为整数,所有的珍珠从1到n编号.你的任务是发现哪颗珍珠的重量刚好处于正中间,即在所有珍珠的重量中,该珍珠的重量列(n+1)/2位.下面 ...

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

随机推荐

  1. Spring Cloud Netflix之Eureka 相关概念

    为什么不应该使用ZooKeeper做服务发现 英文链接:Eureka! Why You Shouldn’t Use ZooKeeper for Service Discovery:http://www ...

  2. ms17010利用失败解决一则

    没有反弹得到session并且提示如下: [-] 10.0.131.2:445 - Service failed to start, ERROR_CODE: 216 换了一个payload set p ...

  3. STM32 volatile关键字

    为了提供对特殊地址的稳定访问. [C] 纯文本查看 复制代码 ? 1 2 3 int i=10; int j=i;     //1 int k=i;    //2 此时编译器对上面代码进行优化,因为在 ...

  4. sicily 4699. 简单哈希

    Description 使用线性探测法(Linear Probing)可以解决哈希中的冲突问题,其基本思想是:设哈希函数为h(key) = d, 并且假定哈希的存储结构是循环数组, 则当冲突发生时,  ...

  5. 2017多校第5场 HDU 6085 Rikka with Candies bitset

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6085 题意:存在两个长度为n,m的数组A,B.有q个询问,每个询问有一个数字k,可以得到Ai%Bj=k ...

  6. dockerfile实例--安装nginx

    [root@localhost ~]# vi Dockerfile //ADD FROM centos_with_net MAINTAINER frankie onez0714@.com RUN yu ...

  7. 全国省市区数据SQL - 省市区

    转载:https://www.cnblogs.com/flywind/p/6036801.html

  8. Struts2学习笔记01 之 简介及配置

    一.Struts简介 * 是轻量级的MVC框架,主要解决了请求分发的问题,重心在控制层和表现层.运用ASOP的思想,使用拦截器来扩展业务控制器 二.使用步骤: 1.引入Sturts2的相关JAR包 2 ...

  9. linux命令(13):kill/killall命令

    停止指定的进程名:kill 进程ID号 把所有httpd进程杀掉:killall httpd 强制停止进程mysqld:killall -9 mysqld

  10. K8S的APISERVER,应用了HTTPS之后,命令行如何访问?

    用命令行总是很麻烦,因为要自定义一些证书的位置....... curl https://1.2.3.1:443/api/v1/nodes \ --cacert /etc/kubernetes/pki/ ...