题目链接: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. thinkphp5操作redis系列教程】列表类型之lRange,lGetRange

    <?php namespace app\admin\controller; use think\cache\driver\Redis; use think\Controller; use \th ...

  2. 搭建单机版spark

    二.下载软件 JDK,Scala,SBT,Maven 版本信息如下: JDK jdk-7u79-linux-x64.gz Scala scala-2.10.5.tgz 三.解压上述文件并进行环境变量配 ...

  3. date和string转换用joda包

    import org.joda.time.DateTime;import org.joda.time.format.DateTimeFormat;import org.joda.time.format ...

  4. git clone慢的解决办法

    转自:http://www.kindemh.cn/ 转自Kindem的博客 问题 大家可能都遇到过从github使用git clone指令奇慢无比的问题,网上很多人说使用代理来加速git,但是这也不是 ...

  5. JavaMail API 发送电子邮件

    现在,我们对JavaMail API及其核心类有一个清晰的概念,现在让我们写这将发送简单的电子邮件,邮件带有附件,电子邮件,HTML内容和电子邮件内嵌图像一个简单的程序. 接着在上述所有情况的基本步骤 ...

  6. js基本包装类型

    基本包装类型   3种特殊的引用类型 为了便于操作基本类型值,es还提供了3种特殊的引用类型: Boolean,Number,String. 每当读取一个基本类型值的时候,后台就会创建一个对应的基本包 ...

  7. Vuex 源码解析

    先来看一下这张Vuex的数据流程图,熟悉Vuex使用的同学应该已经有所了解. Vuex实现了一个单向数据流,在全局拥有一个State存放数据,所有修改State的操作必须通过Mutation进行,Mu ...

  8. mongo之$max

    原集合: { _id: 1, highScore: 800, lowScore: 200 } 应用: #意思是:更新_id 等于1 的记录,条件是highScore 950>原纪录的highSc ...

  9. axios的介绍及使用

    特点:支持promise API . 拦截请求和响应.转换请求数据和响应数据.取消请求.自动转换JSON数据.客户端支持防御XSRF等: axios请求方法(需后端定义):get获取数据. post提 ...

  10. 【转】移动前端开发之viewport的深入理解

    原文链接:https://blog.csdn.net/u012402190/article/details/70172371 笔记 (20180919,目前暂且只看一部分)