POJ 1502 MPI Maelstrom【floyd】

题目大意:求点1到所有点最短路径的最大值

思路:水题,单源最短路,网上解题清一色dijkstra,但是点数小于100显然floyd更简洁嘛

#include<cstdio>

#include<string.h>

#define maxn 101

#define inf 100000

using namespace std;

int read(){

int f=1,x=0;char ch=getchar();

while(ch<‘0‘||ch>‘9‘){if(ch==‘x‘)return inf;ch=getchar();}

while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}return x*f;

}

int n=read(),ans=0,a[maxn][maxn];

int main()

{

for(int i=1;i<=n-1;i++)

for(int j=1;j<=i;j++)a[i+1][j]=a[j][i+1]=read();

for(int k=1;k<=n;k++)

for(int i=1;i<=n;i++)if(i!=k)

for(int j=1;j<=n;j++)if(j!=k&&j!=i&&a[i][k]+a[k][j]<a[i][j])a[i][j]=a[i][k]+a[k][j];

for(int i=2;i<=n;i++)if(a[1][i]>ans)ans=a[1][i];

printf("%d\n",ans);

return 0;

}

时间: 2024-12-30 02:18:08

POJ 1502 MPI Maelstrom【floyd】的相关文章

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: 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 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 1502 MPI Maelstrom

题目链接: http://poj.org/problem?id=1502 题目大意: 有一个信息传递系统,含有n个处理器,传递信息的方式是:刚开始编号为1的处理器拥有信息,他可以传给下一个处理器,然后这两个拥有信息的处理器可以同时向下传递给其他两个处理器,拥有信息的四个处理器再依次如此传递,直到所有处理器都接受到信息的最短时间是多少? 解题思路: 把传递路径画出来,看出可以转化成求从1到其他位置的最短路径中的最长路径,刚看到题目感觉没什么思路,但是建立出来模型以后用dijkstra就好啦! 1

(简单) 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

POJ 1125 Stockbroker Grapevine【floyd】

很裸的floyd #include<cstdio> #include<string.h> #include<algorithm> #define maxn 201 #define inf 100000 using namespace std; int map[maxn][maxn],n,x,y,m;; int main() { while(1) { scanf("%d",&n); if(n==0)break; for(int i=1;i<

POJ 3216 Repairing Company【Floyd + 最小路径覆盖】

大意: 有n个任务,每个任务有三个属性:所在街区,最晚开始时间,执行需要时间 告诉你一个矩阵代表街区间到达时间 告诉你每个任务的三个属性 问最少需要多少人去完成所有任务 分析: floyd处理处任意两个街区的到达时间 拆点   左边集合为n个任务    右边集合跟左边相同 i任务能够到达j任务就从左集合引一条边到右集合 求最小路径覆盖 最小路径覆盖 = n - 最大匹配 代码: 1 #include <iostream> 2 #include <cstdio> 3 #include