poj2139 Six Degrees of Cowvin Bacon
思路:
floyd
实现:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std; int a[][], n, m, k;
const int INF = 0x3f3f3f3f;
int main()
{
memset(a, 0x3f, sizeof(a));
cin >> n >> m;
for (int i = ; i < m; i++)
{
vector<int> l;
int tmp;
cin >> k;
for (int j = ; j < k; j++)
{
cin >> tmp;
l.push_back(tmp);
}
for (int p = ; p < k; p++)
{
for (int q = ; q < k; q++)
{
a[l[p]][l[q]] = p == q ? : ;
}
}
}
for (int k = ; k <= n; k++)
{
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
if (a[i][k] + a[k][j] < a[i][j])
{
a[i][j] = a[i][k] + a[k][j];
}
}
}
}
double __ = INF;
for (int j = ; j <= n; j++)
{
int sum = ;
for (int k = ; k <= n; k++)
{
sum += a[j][k];
}
double ans = sum * 1.0 / (n - );
__ = min(ans, __);
}
cout << (int)(__ * ) << endl;
return ;
}
poj2139 Six Degrees of Cowvin Bacon的更多相关文章
- POJ2139 Six Degrees of Cowvin Bacon [Floyd]
水题,随手敲过 一看就是最短路问题,a,b演同一场电影则他们的距离为1 默认全部两两原始距离无穷,到自身为0 输入全部数据处理后floyd 然后照它说的求平均分离度 再找最小的,×100取整输出 #i ...
- 【Floyd】POJ2139 -Six Degrees of Cowvin Bacon
普通的Floyd了分分秒可以水过,结果在submit前删调试段落的时候把程序本体给删了吃了两个WA…… #include<iostream> #include<cstring> ...
- 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 (floyd)
Six Degrees of Cowvin Bacon Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Ja ...
- 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 最短路径问题 the cow have been making movies
本题链接:http://poj.org/problem?id=2139 Description: The cows have been making movies lately, so the ...
- 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---Floyd
题目链接: https://vjudge.net/problem/POJ-2139 题目大意: 给定一些牛的关系,他们之间的距离为1. 然后求当前这只牛到每只牛的最短路的和,除以 n - 1只牛的最大 ...
随机推荐
- date 命令 时间戳到标准格式转换
1. 知道时间戳看标准时间, 时间戳到 秒: Wed Apr :: CST 2. 看到前时间时间戳格式 date +%s 3. 知道某个标准时间, 看时间戳 date -d "Wed Apr ...
- 【转载】AsyncTask用法
在开发Android应用时必须遵守单线程模型的原则: Android UI操作并不是线程安全的并且这些操作必须在UI线程中执行.在单线程模型中始终要记住两条法则: 1. 不要阻塞UI线程 2. 确保只 ...
- poj 2185 Milking Grid(next数组求最小循环节)
题意:求最小的循环矩形 思路:分别求出行.列的最小循环节,乘积即可. #include<iostream> #include<stdio.h> #include<stri ...
- windows下运行swoole搭建环境
swoole windows环境搭建 swoole框架是一个很神奇很厉害的框架,它弥补了PHP的本身的一些不足之处.其实swoole确切的说是一个使用C语言编写的PHP扩展,并且这个扩展不能够在win ...
- LibSVM学习详细说明
代码文件主要针对Matlab进行说明,但个人仍觉得讲解的支持向量机内容非常棒,可以做为理解这一统计方法的辅助资料; LibSVM是台湾林智仁(Chih-Jen Lin)教授2001年开发的一套支持向量 ...
- Burpsuite实验一
一.实验准备 win7系统 burpsuite 二.实验目的 进行重放攻击,观察结果 三.实验内容 本次实验并没有采取在虚拟机下进行,而是直接在win7系统中进行.首先配置一下环境,选择你常用的浏览器 ...
- Ruby: Print WIN32OLE method names in Ruby
class WIN32OLE def list_ole_methods method_names = ole_methods.collect {|m| m.name} puts m ...
- Python-day-9- RabbitMQ队列
RabbitMQ队列 安装 http://www.rabbitmq.com/install-standalone-mac.html 安装python rabbitMQ module pip insta ...
- 用 SDL2 平铺背景并显示前景
环境:SDL2 + VC++2015 下面的代码将打开background.bmp和image.bmp,将background平铺背景,将image作为前景呈现 #include <iostre ...
- Cascaded pose regression
最近再看face alignment的相关文章,目前比较流行的算法都是基于(Cascaded pose regression,CPR)[1]的框架上做的,该算法之所以流行的原因是简单高效.CPR分为训 ...