题目链接:http://poj.org/problem?id=1502

题意:一个处理器给n-1个处理器发送广播,问最短时间。广播时并发,也就是各个路径就大的一方。输入如果是x的话说明两个处理器不能相互通信。输入是矩阵的左三角。

题解:一个最短路的裸题吧。输入的时候注意一下字符的转换。floyd爆一遍之后再对每个路径找最大值即可。

代码:

 #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std; const int N=;
const int inf = 1e9;
char s[];
int n;
int mp[N][N]; void init(){
for(int i = ; i <= n ;i++){
for(int j = ; j <= n ;j++){
if(i == j){
mp[i][j] = ;
}
else{
mp[i][j] = inf;
}
}
}
}
void floyd(){
for(int k = ; k <= n ; k++){
for(int i = ; i <= n ;i++){
for(int j = ; j <= n ;j++){
mp[i][j] = min(mp[i][j],mp[i][k] + mp[k][j]);
}
}
}
int ans = -inf;
for(int i = ; i <= n ;i++){
if(mp[][i] != inf){
ans = max(ans,mp[][i]);
} }
cout<<ans<<endl;
} int main(){
cin>>n;
init();
for(int i = ; i <= n ;i++){
for(int j = ; j < i; j++){
cin>>s;
if(s[]!= 'x'){
int num = atoi(s);
mp[i][j] = mp[j][i] = num;
}
}
}
floyd();
return ;
}

【POJ】1502 MPI Maelstrom的更多相关文章

  1. (poj)1502 MPI Maelstrom

    题目链接:http://poj.org/problem?id=1502 Description BIT has recently taken delivery of their processor A ...

  2. POJ 1502 MPI Maelstrom / UVA 432 MPI Maelstrom / SCU 1068 MPI Maelstrom / UVALive 5398 MPI Maelstrom /ZOJ 1291 MPI Maelstrom (最短路径)

    POJ 1502 MPI Maelstrom / UVA 432 MPI Maelstrom / SCU 1068 MPI Maelstrom / UVALive 5398 MPI Maelstrom ...

  3. 【POJ】1704 Georgia and Bob(Staircase Nim)

    Description Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, ...

  4. 【POJ】1067 取石子游戏(博弈论)

    Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后 ...

  5. POJ 1502 MPI Maelstrom(最短路)

    MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4017   Accepted: 2412 Des ...

  6. POJ 1502 MPI Maelstrom

    MPI Maelstrom Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) Total ...

  7. POJ 1502 MPI Maelstrom (最短路)

    MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6044   Accepted: 3761 Des ...

  8. POJ - 1502 MPI Maelstrom 路径传输Dij+sscanf(字符串转数字)

    MPI Maelstrom BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odys ...

  9. POJ 1502 MPI Maelstrom [最短路 Dijkstra]

    传送门 MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5711   Accepted: 3552 ...

随机推荐

  1. php开发面试题---vue面试题(vue.js的好处及作用)

    php开发面试题---vue面试题(vue.js的好处及作用) 一.总结 一句话总结: 双向数据绑定:在做ajax的时候,更新实在是太方便了 用数据绑定的思想,vue可以简单写单个页面,也可以写一个大 ...

  2. bootstrap 的 datetimepicker,同时有日期和时间, 且开始时间要早于结束时间

    首先,引入jquery, bootstrap 和 bootstrap-datetimepicker datetimepicker的下载地址: http://www.bootcss.com/p/boot ...

  3. error LNK2001: unresolved external symbol "public: __thiscall CWinAppEx::CWinAppEx(int)" (??0CWinApp

    1.这个是网上找的别人的解决办法,本人没试过 解决办法: 网上大多说的这类似问题是解决自定义类的,可是这个连接是系统CWinAppEx,网上查了很久也没找到原因,重装了vs也没解决.后面在google ...

  4. 浅谈HP-Socket在物联网的应用

    原文链接:https://my.oschina.net/chrisforbt/blog/1669746 一.应用背景 去年公司成立了个项目——<智慧用电安全隐患监管服务平台>,计划是开发一 ...

  5. mvn eclipse:eclipse

    pom.xml 在哪个文件夹, 你就在哪里按shift 右键,,[在此处打开命令窗口]  执行那个命令. mvn eclipse:eclipse

  6. PAT_A1028#List Sorting

    Source: PAT A1028 List Sorting (25 分) Description: Excel can sort records according to any column. N ...

  7. Codeforcs 1183B Equalize Prices

    题目链接:codeforces.com/problemset/problem/1183/B 题意:给你 n 个数,每个数能在k范围内上下浮动,求能否使所有数相等,能输出相等的最大值,不能输出 -1. ...

  8. 拾遗:ssh 公钥连接前的相关准备

    ssh 公钥连接条件: sshd_config 中启用公钥认证 authorized_keys 文件权限必须为 0600 目标用户的 家目录 权限必须为 0700 目标账户必须已设定登陆密码(即处于可 ...

  9. ThinkPHP5实用的数据库操作方法

    1.update方法总结 /** * 设置记录的某个字段值 * 支持使用数据库字段和方法 * @access public * @param string|array $field 字段名 * @pa ...

  10. 209. Minimum Size Subarray Sum【滑动窗口】

    Given an array of n positive integers and a positive integer s, find the minimal length of a contigu ...