很裸的floyd

#include<cstdio>

#include<string.h>

#include<algorithm>

#define maxn 201

#define inf 100000

using namespace std;

int map[maxn][maxn],n,x,y,m;;

int main()

{

while(1)

{

scanf("%d",&n);

if(n==0)break;

for(int i=1;i<=n;i++)

for(int j=1;j<=n;j++)

map[i][j]=inf;

for(int i=1;i<=n;i++)

{

scanf("%d",&m);

for(int j=1;j<=m;j++)

scanf("%d%d",&x,&y),map[i][x]=y;

}

for(int k=1;k<=n;k++)

for(int i=1;i<=n;i++)if(k!=i)

for(int j=1;j<=n;j++)if(j!=k&&j!=i&&map[i][k]+map[k][j]<map[i][j])

map[i][j]=map[i][k]+map[k][j];

int ans=inf,ansj=-1;

for(int i=1;i<=n;i++)

{

int tem=-1;

for(int j=1;j<=n;j++)

{

if(map[i][j]>tem&&map[i][j]!=inf)tem=map[i][j];

if(map[i][j]==inf&&i!=j){tem=-1;break;}

}

if(tem<ans&&tem!=-1)ans=tem,ansj=i;

}

if(ansj==-1)printf("disjoint\n");else

printf("%d %d\n",ansj,ans);

}

return 0;

}

POJ 1125 Stockbroker Grapevine【floyd】的更多相关文章

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

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

  2. POJ 1125 Stockbroker Grapevine(floyd)

    http://poj.org/problem?id=1125 题意 : 就是说想要在股票经纪人中传播谣言,先告诉一个人,然后让他传播给其他所有的经纪人,需要输出的是从谁开始传播需要的时间最短,输出这个 ...

  3. 最短路(Floyd_Warshall) POJ 1125 Stockbroker Grapevine

    题目传送门 /* 最短路:Floyd模板题 主要是两点最短的距离和起始位置 http://blog.csdn.net/y990041769/article/details/37955253 */ #i ...

  4. OpenJudge/Poj 1125 Stockbroker Grapevine

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

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

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

  6. POJ 1125 Stockbroker Grapevine

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

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

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

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

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

  9. Poj 1125 Stockbroker Grapevine(Floyd算法求结点对的最短路径问题)

    一.Description Stockbrokers are known to overreact to rumours. You have been contracted to develop a ...

随机推荐

  1. PHP小数处理常用函数

    1.php保留两位小数并且四舍五入 $num = 123213.666666; echo sprintf("%.2f", $num); // 123213.67echo round ...

  2. 通过 Azure IoT 中心实现互联网设备数据的可视化分析

    本课程主要介绍了如何 在Azure 平台上借助 Azure IoT 中心, Azure 流分析,Web 应用, Azure 数据库等服务快速构建收集处理并可视化来自设备的数据流的应用, 包括项目背景介 ...

  3. codevs 1145 Hanoi双塔问题 2007年NOIP全国联赛普及组

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description 给定A.B.C三根足够长的细柱,在A柱上放有2n个中间有孔的圆盘,共有n个不同的 ...

  4. mac ssd开启trim模式

    开启方法 sudo trimforce enable

  5. make 与makefile(会不会写 makefile,从一个侧面说明了一个人是否具备完成大型工程的能力。)

    跟我一起写 Makefile /**/ 陈皓 (CSDN) 概述 —— 什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉 ...

  6. winhex 中磁盘大小与偏移

    下图为c盘(活动分区).上方base offset为相对于整个硬盘的字节偏移量.partition 1中信息包括c盘开始扇区,总扇区数.partition 2 信息为扩展分区开始扇区和扇区数.由 P1 ...

  7. 三、绘图和可视化之matplotlib

    #matplotlib简单绘图之plot import matplotlib.pyplot as plt a=[1,2,3] b=[10,2,30] plt.plot(a)#纵坐标为a的值,横坐标为a ...

  8. 爬虫_python3_urllib

    urlib库为python3的HTTP内置请求库 urilib的四个模块: urllib.request:用于获取网页的响应内容 urllib.error:异常处理模块,用于处理异常的模块 urlli ...

  9. 如何禁用Visual Studio的Browser Link功能

    在Web.Config的AppSetting节点添加<add key="vs:EnableBrowserLink" value="false"/>

  10. Spring根据XML配置文件注入属性 其实也是造bean,看看是使用constructor还是setter顺带完成属性赋值

    方法一使用setter方法 package com.swift; public class Book { private String bookName; public void setBook(St ...