题目链接: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. Installing GCC 简单方法

    Installing GCC This page is intended to offer guidance to avoid some common problems when installing ...

  2. C++——数据结构之链表

    直接上例子 int main() { ,,}; ,,}; Listnode *head=NULL,*temp; head=(Listnode*)malloc(sizeof(Listnode));//头 ...

  3. Intel Pin基础

    参考:http://software.intel.com/sites/landingpage/pintool/docs/62732/Pin/html/ http://blog.nruns.com/bl ...

  4. python输入一个\输出2个\问题

    在Python里面,如果\后面不是一个合法的转移字符,那么,Python会打印两个\,换句话说,Python将\也当成普通字符看待,而不是转义符的标志: >>>S = 'C:\py\ ...

  5. 欧拉筛 线性筛 素数+莫比乌斯的mu[]

    https://blog.csdn.net/qq_39763472/article/details/82428602 模板来自https://blog.csdn.net/Avalon_cc/artic ...

  6. JS数组 选定元素slice() slice() 方法可从已有的数组中返回选定的元素。 语法 arrayObject.slice(start,end)

    选定元素slice() slice() 方法可从已有的数组中返回选定的元素. 语法 arrayObject.slice(start,end) 参数说明: 1.返回一个新的数组,包含从 start 到 ...

  7. 驾驶心率和呼吸,疲劳检测系统,通过安全带,坐垫等内置sensor

    HARKEN - Heart and respiration in car embedded nonintrusive sensors 2 https://www.youtube.com/watch? ...

  8. wkhtmltopdf linux下html转pdf

    https://blog.csdn.net/wujunlei1595848/article/details/91129197 https://github.com/wkhtmltopdf/wkhtml ...

  9. main中的argc,argv

    那么我们运行程序时,传入的参数,就是这个argc的值:从截图中,我们很清楚的可以看出,argc是传入参数的个数,”传入的参数“加上可执行文件的文件名:  

  10. 26.String类(1)

    1. 下面是一个使用equals的例子: 我查看了一下源代码,string类中equals方法的源代码如下: public boolean equals(Object anObject) { if ( ...