题目链接: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. 资源-.Net-ASP.NET:ASP.NET资源列表

    ylbtech-资源-.Net-ASP.NET:ASP.NET资源列表 ASP.NETFree. Cross-platform. Open source.A framework for buildin ...

  2. (3)centos7 目录结构

    根目录下的文件下 根目录:  /   注意:根目录只存放目录,并且/etc./bin./dev./lib./sbin应该和根目录放置在一个分区中 /bin 二进制目录,存放用户级的GUN工具  /bo ...

  3. 1.3 React 组件

    1.3.1 React 组件介绍 在 React 中组件是第一元素,是 React 的基础,一个 React 应用就是基于 React 组件的组合而成.前面的 JSX 练习过后,大家应该对 React ...

  4. UVA 11178 Morley's Theorem (坐标旋转)

    题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...

  5. 第五记 JDBC

    了解JDBC JDBC(Java DataBase Connectivity,java数据库连接)是一种用于执行SQL语句的Java API(API:Application Program Inter ...

  6. Samcompu Loves Water

    题目背景 Samcompu拥有大量的"水"资源!! 题目描述 Samcompu需要制定一个水计划.这个计划的主要目的就是为了避开老师监视的时间来水. 老师在中途会离开机房T次,第i ...

  7. 【转】从SOA到微服务,企业分布式应用架构在云原生时代如何重塑

    摘要: SOA 采用中心化的服务总线架构,解耦了业务逻辑和服务治理逻辑:微服务架构回归了去中心化的点对点调用方式,在提升敏捷性和可伸缩性的同时,也牺牲了业务逻辑和服务治理逻辑解耦所带来的灵活性. 为了 ...

  8. Python 分解质因数

    def zys(n, value=[]): for i in range(2, int(n / 2 + 1)): if n % i == 0: value.append(i) zys(n / i, v ...

  9. Ruby 类和对象

    Ruby 类和对象 Ruby 是一种完美的面向对象编程语言.面向对象编程语言的特性包括: 数据封装 数据抽象 多态性 继承 这些特性将在 面向对象的 Ruby 中进行讨论. 一个面向对象的程序,涉及到 ...

  10. NX二次开发-UFUN创建B面UF_MODL_create_bsurf

    NX9+VS2012 #include <uf.h> #include <uf_modl.h> //创建一个B面 ;//U方向极数 ;//V方向极数 ;//U方向规则 ;//V ...