题目:http://poj.org/problem?id=1125

题意:给出一个社交网络,每个人有几个别人可以传播谣言,传播谣言需要时间。问要使得谣言传播的最快,应该从那个人开始传播谣言以及使得所有人都知道这个谣言需要多少时间,、

时间的定义是使得最后一个人知道这个谣言的时间。多元最短路

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<stack>
#include<queue>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std; const int INF= <<;
int G[][],n;
int min_n(int a,int b)
{
return a>b?b:a;
}
void floyd()
{
int i,j,k;
for(k=; k<=n; k++)
for(i=; i<=n; i++)
for(j=; j<=n; j++)
G[i][j]=min_n(G[i][j],G[i][k]+G[k][j]);
}
int main()
{
int i,j,m,a,b,f,ans,x,y;
while(cin>>n&&n)
{
for(i=; i<=n; i++)
{
for(j=; j<=n; j++)
G[i][j]=INF;
G[i][i]=;
}
for(i=; i<=n; i++)
{
cin>>m;
while(m--)
{
cin>>a>>b;
if(G[i][a]>b)
G[i][a]=b;
}
}
floyd();
f = ; x = INF;
for(i=; i<=n; i++)
{
ans=-;
for(j=; j<=n; j++)
{
if(G[i][j]>=INF)
break;
if(ans<G[i][j])
ans=G[i][j];
}
if(j==n+)
{
f=;
if(x>ans)
{
x=ans;
y=i;
}
}
}
if(f) printf("%d %d\n",y,x);
else cout<<"disjoint"<<endl;
}
return ;
}

即  找一个最长 的

poj 1125 Stockbroker Grapevine(最短路 简单 floyd)的更多相关文章

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

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

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

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

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

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

  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最短路)

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

  9. POJ 1125 Stockbroker Grapevine(floyd)

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

随机推荐

  1. android studio引入第三方包记录

    1.添加jar文件 将jar文件复制至app module目录下的libs文件夹下,然后打开app module目录下的build.gradle配置文件,在dependencies项中添加配置命令,这 ...

  2. 关于maven参数过滤

    一.maven通过设置过滤器,可以使maven在编译打包时实现参数过滤的功能(详细配置说明略) <filters> <filter>../antx.properties< ...

  3. 【Vmware】已有镜像文件的导入

    1  虚拟机文件夹中各个文件简介 在创建虚拟机的时候会把相关的文件保存到一个文件夹中.我的机器是Windows 7,64位 ,保存的路径是: C:\Users\User\Documents\Virtu ...

  4. MySQL Connector Net连接vs2012问题

    最近做一.NET项目,数据库用到MySQL,可是在VS2012连接数据库是遇到问题,提示:Authentication with old password no longer supported, u ...

  5. The Black Hole of Numbers (strtoint+inttostr+sort)

    For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in ...

  6. 五、mysql存储引擎

    show variable like 'table_type'; 显示系统默认存储引擎 show engine\G 显示系统支持存储殷勤 =============================== ...

  7. 如何查看windows操作系统当前使用的字符集

    如何查看windows操作系统当前使用的字符集 Chcp 显示活动控制台代码页数量,或更改该控制台的活动控制台代码页.如果在没有参数的情况下使用,则 chcp 显示活动控制台代码页的数量. 语法 ch ...

  8. github简单使用

    github是一个基于git的代码托管平台,付费用户可以建私人仓库,我们一般的免费用户只能使用公共仓库,也就是代码要公开.对于一般人来说公共仓库就已经足够了,而且我们也没多少代码来管理,O(∩_∩)O ...

  9. TWaver初学实战——如何在TWaver属性表中添加日历控件?

    在日期输入框中添加日历控件,是一种非常流行和实用的做法.临渊羡鱼不如退而写代码,今天就看看在TWaver中是如何实现的.   资源准备   TWaver的在线使用文档中,就有TWaver Proper ...

  10. bnu 4358 左手定则 (搜索)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=4358 [题意]:给定起始位置和方向和目的地,按照左转.前进.右转.后退的优先级递减,也就是说能左转就 ...