题目链接: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. Go 方法、接口

        在 Go 中,类型可以定义接收此类型的函数,即方法.每个类型都有接口,意味着对那个类型定义了方法集合. 下面定义了结构体类型 S 以及它的两个方法: type S struct { i int ...

  2. TI低功耗蓝牙(BLE)介绍【转】

    转自:http://blog.csdn.net/ooakk/article/details/7302425 TI低功耗蓝牙(BLE)介绍 本文档翻译和修改自参考资料:CC2540Bluetooth L ...

  3. 10、TestNG 的 FixTrue用法一

    Fixture 是指一个测试运行所需的固定环境,通俗来说 ,为测试用例所准备的环境. 以下是TestNG中可用的注释及其属性的简要概述. 我们先演示@BeforeClass.@AfterClass.@ ...

  4. 通过Module读取寄存器的值

    1: int eax; 2: _asm_("nop":"=a"(eax)); 3: printk("Get Eax Value:\n"); ...

  5. DLL 调用 对话框 以及 如何获取调用dll 应用程序(窗口程序)的窗口句柄

    1.一般创建需要的窗口,转换成相应的窗口类: 声明一个导出函数,来处理窗口的显示,如: CTest test; extern "C" __declspec(dllexport) v ...

  6. pycharm的第一次使用(其实并不是第一次)

    file --> settings --> editor -->general --> change font size file --> settings --> ...

  7. 7-vim-移动命令-02-行数跳转和上下翻页

    1.行数跳转 命令 英文 功能 gg go 文件顶部 G GO 文件尾部 数字gg   移动到数字对应行数 数字G   移动到数字对应行数 :数字   移动到数字对应行数 2.屏幕移动 命令 英文 功 ...

  8. HTTP信息头处理器

    就是HTTP请求头-Header

  9. JavaScript中this对象原理简洁说明

    今天看了阮一峰大神的博客文章:JavaScript 的this原理,把纠结很久的this的指向终于理解清楚了 原文:http://www.ruanyifeng.com/blog/2018/06/jav ...

  10. vue之父子组件执行对方的方法

    一.子组件执行父组件中的方法 1.父组件将方法名传给子组件,子组件进行调用 父组件中: <Vbutton typeBtn="success" :btnUserMethod=& ...