题目传送门

 /*
最短路:Floyd模板题
主要是两点最短的距离和起始位置
http://blog.csdn.net/y990041769/article/details/37955253
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
using namespace std; const int MAXN = + ;
const int INF = 0x3f3f3f3f;
int d[MAXN][MAXN]; void Floyd_Warshall(int n)
{
for (int k=; k<=n; ++k)
{
for (int i=; i<=n; ++i)
{
for (int j=; j<=n; ++j)
{
if (d[i][j] > d[i][k] + d[k][j])
d[i][j] = d[i][k] + d[k][j];
}
}
}
} void work(int n)
{
Floyd_Warshall (n);
int res; int ans = INF; int num;
for (int i=; i<=n; ++i)
{
res = ;
for (int j=; j<=n; ++j)
{
if (i == j) continue;
if (res < d[i][j]) res = d[i][j];
}
if (ans > res)
{
ans = res;
num = i;
}
} printf ("%d %d\n", num, ans);
} int main(void) //POJ 1125 Stockbroker Grapevine
{
//freopen ("E.in", "r", stdin); int n, m;
while (~scanf ("%d", &n) && n)
{
for (int i=; i<=n; ++i)
for (int j=; j<=n; ++j) d[i][j] = INF;
for (int i=; i<=n; ++i)
{
scanf ("%d", &m);
int x, y;
for (int j=; j<=m; ++j)
{
scanf ("%d%d", &x, &y);
d[i][x] = y;
}
} work (n);
} return ;
}

最短路(Floyd_Warshall) POJ 1125 Stockbroker Grapevine的更多相关文章

  1. OpenJudge/Poj 1125 Stockbroker Grapevine

    1.链接地址: http://poj.org/problem?id=1125 http://bailian.openjudge.cn/practice/1125 2.题目: Stockbroker G ...

  2. POJ 1125 Stockbroker Grapevine【floyd简单应用】

    链接: http://poj.org/problem?id=1125 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...

  3. poj 1125 Stockbroker Grapevine(多源最短)

    id=1125">链接:poj 1125 题意:输入n个经纪人,以及他们之间传播谣言所需的时间, 问从哪个人開始传播使得全部人知道所需时间最少.这个最少时间是多少 分析:由于谣言传播是 ...

  4. POJ 1125 Stockbroker Grapevine

    Stockbroker Grapevine Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 33141   Accepted: ...

  5. poj 1125 Stockbroker Grapevine dijkstra算法实现最短路径

    点击打开链接 Stockbroker Grapevine Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23760   Ac ...

  6. poj 1125 Stockbroker Grapevine(最短路 简单 floyd)

    题目:http://poj.org/problem?id=1125 题意:给出一个社交网络,每个人有几个别人可以传播谣言,传播谣言需要时间.问要使得谣言传播的最快,应该从那个人开始传播谣言以及使得所有 ...

  7. POJ 1125 Stockbroker Grapevine 最短路 难度:0

    http://poj.org/problem?id=1125 #include <iostream> #include <cstring> using namespace st ...

  8. POJ 1125 Stockbroker Grapevine(最短路基础题)

    Stockbrokers are known to overreact to rumours. You have been contracted to develop a method of spre ...

  9. POJ 1125 Stockbroker Grapevine (Floyd最短路)

    Floyd算法计算每对顶点之间的最短路径的问题 题目中隐含了一个条件是一个人能够同一时候将谣言传递给多个人 题目终于的要求是时间最短.那么就要遍历一遍求出每一个点作为源点时,最长的最短路径长是多少,再 ...

随机推荐

  1. 浅谈setTimeout函数和setInterval函数

    前几天学了js,看到了两个非常有趣的函数,他们分别是setTimeout函数和setInterval函数,这两个函数能使网页呈现非常一些网页中比较常见的效果,比如说图片轮播,等一些非常好玩的效果.下面 ...

  2. Android学习笔记之打钩显示输入的密码

    利用EditText作为密码输入框是个不错的选择(只需设置输入类型为textPassword即可),保密且无需担心被盗取.但有时用户也不知道自己输入的是否正确,这时就应该提供一个“显示密码”的复选框, ...

  3. Linux下的网络管理工具—OpenNMS

    导读 OpenNMS的是一个运营商级别的,高度集成的,开放源码的平台,用于构建网络监控解决方案.OpenNMS有两个发行版:Meridian and Horizon.使用Meridian是可取的,对企 ...

  4. 基于2d Tool Kit 精灵合图,动作生成工具

    http://blog.csdn.net/onerain88/article/details/18563687 2d Tool Kit 是一款出色的基于unity3d 开发2d游戏的工具,提供了丰富的 ...

  5. Difference between git pull and git pull --rebase

    个人博客地址:  http://www.iwangzheng.com/ 推荐一本非常好的书 :<Pro Git>  http://iissnan.com/progit/ 构造干净的 Git ...

  6. MySQL目录

    MySQL的学习总结目录 Mysql5.7安装及配置 教你如何3分钟玩转MYSQL MySQL使用详解--根据个人学习总结 Mysql增删改 Mysql_以案例为基准之查询 MySQL之扩展(触发器, ...

  7. BZOJ 1452 [JSOI2009] Count

    这道题好像有点简单的样子... absi找题目好厉害啊...确实是一道比较裸的2dBIT啊. 水掉吧. 附:2dBIT怎么做: 2dBIT就是BIT套BIT啦. 所以修改loop(x+=lowbit( ...

  8. Laravel 5 系列入门教程(一)【最适合中国人的 Laravel 教程】

    Laravel 5 系列入门教程(一)[最适合中国人的 Laravel 教程] 分享⋅ johnlui⋅ 于 2年前 ⋅ 最后回复由 skys215于 11个月前 ⋅ 17543 阅读   原文发表在 ...

  9. Junit4测试

    1.junit初级入门 2.常用注解 3.运行流程 4.测试套件使用 5.参数化设置

  10. 30.赋值运算符重载函数[Assign copy constructor]

    [问题] 给出如下CMyString的声明,要求为该类型添加赋值运算符函数.  C++ Code  1234567891011   class CMyString { public:     CMyS ...