POJ 1125-Stockbroker Grapevine
来源:互联网 发布:诺基亚6600s软件 编辑:程序博客网 时间:2024/06/10 19:55
题目链接:Stockbroker Grapevine
题意: n个人炒股,每个人都可以给其他人报信,第 1 行 n,第x行 第一个 是 第 x-1个人可以给几个人报信,后面是能给哪些人报信和报信的时间 ,问从第几个人开始报信所用的时间最少
水题,Floyd 一遍 过;
ME 676KB
TI 16MS
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <algorithm>const int INF = 1e7;const int N = 105;using namespace std;int mapp[N][N],n;void init(){ for(int i = 1;i<=n;i++) { for(int j = 1;j<=n;j++) { mapp[i][j] = INF; } }}void Floyd(){ int k,j,i; for(k = 1;k<=n;k++) { for(i = 1;i<=n;i++) { for(j=1;j<=n;j++) { if(mapp[i][j] > mapp[i][k] + mapp[k][j]) mapp[i][j] = mapp[k][j] + mapp[i][k]; } } }}int main(){ int s,wz,ti; while(scanf("%d",&n),n) { init(); for(int i = 1;i<=n;i++) { scanf("%d",&s); for(int j = 1;j<=s;j++) { scanf("%d%d",&wz,&ti); mapp[i][wz] = ti; } } Floyd(); int st = -1,maxx = 0,ti = INF; for(int i = 1;i<=n;i++) { maxx = 0; for(int j = 1;j<=n;j++) { if(i==j) continue; if(mapp[i][j]> maxx) { maxx = mapp[i][j]; } } if(ti>maxx) { ti = maxx; st = i; } } if(st!=-1) printf("%d %d\n",st,ti); else puts("disjoint"); } return 0;}
0 1
- poj 1125 Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- poj 1125 Stockbroker Grapevine
- poj 1125 Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- poj 1125 Stockbroker Grapevine
- Poj 1125 Stockbroker Grapevine
- poj 1125 Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- poj 1125-Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- poj 1125 Stockbroker Grapevine
- poj 1125 Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- POJ 1125 Stockbroker Grapevine
- 回文数另一解
- zabbix2.2.3中乱码的解决方法
- 20140613_JavaWeb学习之开发环境配置篇
- QML官方教程——Qt Quick Layouts Overview
- centos 配置
- POJ 1125-Stockbroker Grapevine
- 关于在web上经常用到的省市关联
- Windows下u-boot-2011.03在Mini2440移植详解(2)
- Android 基础理论 day01
- POJ 1511——Invitation Cards(最短路)
- 详解MapReduce算法
- 还是这个好点
- EditText自适应高度
- 介绍PAM