POJ 1125 Stockbroker Grapevine 最短路 难度:0
http://poj.org/problem?id=1125
#include <iostream>
#include <cstring>
using namespace std;
int d[101][101];// dag ATTENTION
int num[101];//the number of contracts
int edge[101][101];// adjecent edge table
int n;//always represent the maxnum of single data
bool input(){
if((cin>>n)==NULL)return false;
if(n==0)return false;
for(int i=0;i<n;i++){
memset(d+i,0x3f,n*sizeof(int));
cin>>num[i];
int temp;
for(int j=0;j<num[i];j++){
cin>>temp;
temp--;
edge[i][j]=temp;
cin>>d[i][temp];
}
}
return true;
}
void solve(){
for(int k=0;k<n;k++){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
d[i][j]=min(d[i][k]+d[k][j],d[i][j]);
}
}
}
int maxn=0;
int ans=0x3f3f;
int ansn;
for(int i=0;i<n;i++){
maxn=0;
for(int j=0;j<n;j++){
if(j!=i)maxn=max(maxn,d[i][j]);
}
if(ans>maxn){
ansn=i;
ans=maxn;
}
}
cout<<ansn+1<<" "<<ans<<"\n";
}
int main(){
while(input()){
solve();
}
return 0;
}
POJ 1125 Stockbroker Grapevine 最短路 难度:0的更多相关文章
- 最短路(Floyd_Warshall) POJ 1125 Stockbroker Grapevine
题目传送门 /* 最短路:Floyd模板题 主要是两点最短的距离和起始位置 http://blog.csdn.net/y990041769/article/details/37955253 */ #i ...
- OpenJudge/Poj 1125 Stockbroker Grapevine
1.链接地址: http://poj.org/problem?id=1125 http://bailian.openjudge.cn/practice/1125 2.题目: Stockbroker G ...
- POJ 1125 Stockbroker Grapevine【floyd简单应用】
链接: http://poj.org/problem?id=1125 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...
- poj 1125 Stockbroker Grapevine(多源最短)
id=1125">链接:poj 1125 题意:输入n个经纪人,以及他们之间传播谣言所需的时间, 问从哪个人開始传播使得全部人知道所需时间最少.这个最少时间是多少 分析:由于谣言传播是 ...
- POJ 1125 Stockbroker Grapevine
Stockbroker Grapevine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 33141 Accepted: ...
- poj 1125 Stockbroker Grapevine dijkstra算法实现最短路径
点击打开链接 Stockbroker Grapevine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 23760 Ac ...
- poj 1125 Stockbroker Grapevine(最短路 简单 floyd)
题目:http://poj.org/problem?id=1125 题意:给出一个社交网络,每个人有几个别人可以传播谣言,传播谣言需要时间.问要使得谣言传播的最快,应该从那个人开始传播谣言以及使得所有 ...
- POJ 1125 Stockbroker Grapevine(最短路基础题)
Stockbrokers are known to overreact to rumours. You have been contracted to develop a method of spre ...
- POJ 1125 Stockbroker Grapevine (Floyd最短路)
Floyd算法计算每对顶点之间的最短路径的问题 题目中隐含了一个条件是一个人能够同一时候将谣言传递给多个人 题目终于的要求是时间最短.那么就要遍历一遍求出每一个点作为源点时,最长的最短路径长是多少,再 ...
随机推荐
- mysql SQL_CALC_FOUND_ROWS
mysql> ,; +----+ | id | +----+ | | | | | | | | | | +----+ rows | +--------------+ ro ...
- 【Todo】OSGi学习
经常听到.见到OSGi这个名字.那么就单开一篇文章记录一下对OSGi的学习吧. 主要是做一些概念上面的学习.暂时不打算深入实践. 主要参考:http://www.osgi.com.cn/article ...
- Wincap安装出现“error opening file for writing wpcap.dll”之解决办法
Wincap安装出现"error opening file for writing wpcap.dll"之解决办法 安装Wireshark时,一直出现下面的错误,选择忽略这个错误, ...
- swift语言学习之UITableView分割线左边到头的解决
此方法兼容ios 7.8.9 // 在tableView创建地方设置 if tableView!.respondsToSelector("setSeparatorInset:") ...
- C++模板(基础)
本文转至:http://www.cnblogs.com/gw811/archive/2012/10/25/2738929.html C++模板 模板是C++支持参数化多态的工具,使用模板可以使用户为类 ...
- 转:C 函数调用栈
第一篇: 转自:http://kingj.iteye.com/blog/1555017 本文转自 http://blog.csdn.net/eno_rez/article/details/21586 ...
- final运用于内部类访问局部变量
final运用于内部类访问局部变量 public void mRun( final String name){ new Runnable() { @Override public void run() ...
- JS 判断当前使用浏览器名及版本
由于我的后台系统的上传图片不支持IE浏览器的,所以我需要判断公司人员在使用后台系统的时候,是否使用的浏览器是IE的. // 获取当前浏览器名 及 版本号 function appInfo(){ var ...
- 界面显示这个时间格式的js代码: 2016年1月19日 星期二 乙未(羊)年 腊月初十
today=new Date();function initArray(){ this.length=initArray.arguments.length for(var i=0;i<this. ...
- 【hdu2196】Computer
hdu 2196 computer 题意 给你一棵树,边有权值. 对于每一个点,求其与其距离最远的点的距离. 分析 思路1:树的直径 利用直径的性质进行求解,网上资料很多,这里不赘述. #includ ...