UVa 423 - MPI Maelstrom

题目:n个机器之间传递信息,求最长的传递时间。

分析:最短路。数据较小,任何一种最短路算法都可以解决。

说明:单源最短路(⊙_⊙)。

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

#define Inf 0x7fffffff

int g[101][101];

int main()
{
	int  n;
	char buf[256];
	while (~scanf("%d",&n)) {
		for (int i = 0 ; i < n ; ++ i) {
			for (int j = 0 ; j < i ; ++ j) {
				scanf("%s",buf);
				if (buf[0] != 'x')
					g[i][j] = g[j][i] = atoi(buf);
				else g[i][j] = g[j][i] = Inf;
			}
			g[i][i] = 0;
		}

		for (int k = 0 ; k < n ; ++ k)
		for (int i = 0 ; i < n ; ++ i)
		for (int j = 0 ; j < n ; ++ j)
			if (g[i][k] != Inf && g[k][j] != Inf && g[i][j] > g[i][k]+g[k][j])
				g[i][j] = g[i][k]+g[k][j];

		int Max = 0;
		for (int i = 0 ; i < n ; ++ i)
			if (Max < g[0][i])
				Max = g[0][i];

		printf("%d\n",Max);
	}
    return 0;
}
时间: 2024-10-19 09:06:16

UVa 423 - MPI Maelstrom的相关文章

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

MPI Maelstrom(poj1502)(迪杰斯特拉+atoi函数)

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

MPI Maelstrom(East Central North America 1996)(poj1502)

MPI Maelstrom 总时间限制:  1000ms 内存限制:  65536kB 描述 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

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

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 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。

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 Swigert, has asked her to be