MPI Maelstrom POJ - 1502 floyd

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
const int N=110;
const int INF = 0x3f3f3f3f;
char s[20];
int n;
int f[N][N];
void init()
{
    for(int i = 1 ; i <=  n ; i++)
        for(int j = 1; j <= n ; j++)
            if(i == j)
                f[i][j] = 0;
            else
                f[i][j] = INF ;

}
void floyd()
{
    for(int k = 1; k <= n ; k++)
        for(int i = 1; i <= n ; i++)
            for(int j = 1; j <= n ; j++)
                f[i][j] = min(f[i][j],f[i][k] +f[k][j]);
    int ans = -INF ;
    for(int i = 1; i <= n ; i++)
        if(f[1][i] !=INF)
            ans = max(ans,f[1][i]);
    cout<<ans<<endl;
}
int main()
{
    cin>>n;
    init();
    for(int i = 2; i <= n ; i++)
        for(int j = 1; j < i; j++)
        {
            cin>>s;
            if(s[0]!= ‘x‘)
            {
                int num = atoi(s);
                f[i][j] = f[j][i] = num;
            }
        }
    floyd();
    return 0;
}

原文地址:https://www.cnblogs.com/QingyuYYYYY/p/12235784.html

时间: 2024-10-13 16:18:07

MPI Maelstrom POJ - 1502 floyd的相关文章

MPI Maelstrom POJ 1502

http://poj.org/problem?id=1502 题意:这是一个下三角,上三角跟下三角图形一致,(若是完整的矩阵的话, 相当于 Map[i][j] 的距离为相对应的数值)这道题也一样. 不同的是 若 显示的为 ‘x’字母时, 说明Map[i][j]为正无穷, 两个点之间不通. 现在的问题是:求1到2, 1到3, .... 1到n 之中哪条路是最短的. **** 英语真的是太渣,表示看懂题意不是一般的难啊, 但是看懂题意后真的好简单 %>_<% .. 不要再考我英语了,我诚实的说四级

MPI Maelstrom POJ - 1502 最短路Dijkstra

BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advisor, Jack Swigert, has asked her to benchmark the

kuangbin专题专题四 MPI Maelstrom POJ - 1502

题目链接:https://vjudge.net/problem/POJ-1502 dijkstra板子题,题目提供下三角情况,不包含正对角线,因为有题意都为0,处理好输入,就是一个很水的题. 1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 #include <cstdio> 5 #include <string> 6 #include <vector&g

POJ 1502 MPI Maelstrom (Dijkstra 模板题)

MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5877   Accepted: 3654 Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchic

poj 1502 MPI Maelstrom(最短路)

poj 1502 MPI Maelstrom Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advisor, Jack Swige

poj 1502 MPI Maelstrom Dijkstra算法的简单运用 ,呵呵,,我估计有很多人都没看懂什么意思,我也看了很久

MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5831   Accepted: 3621 Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchic

POJ 1502 MPI Maelstrom (最短路)

MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6329   Accepted: 3925 Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchic

POJ 1502 MPI Maelstrom [最短路 Dijkstra]

传送门 MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5711   Accepted: 3552 Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierar

POJ 1052 MPI Maelstrom

MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5547   Accepted: 3458 Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchic