题目链接:http://poj.org/problem?id=1502

Description

BIT has recently taken delivery of their new supercomputer, a  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 new system.
``Since the Apollo is a distributed shared memory machine, memory access and communication times are not uniform,'' Valentine told Swigert. ``Communication is fast between processors that share the same memory subsystem, but it is slower between processors that are not on the same subsystem. Communication between the Apollo and machines in our lab is slower yet.'' ``How is Apollo's port of the Message Passing Interface (MPI) working out?'' Swigert asked. ``Not so well,'' Valentine replied. ``To do a broadcast of a message from one processor to all the other n- processors, they just do a sequence of n- sends. That really serializes things and kills the performance.'' ``Is there anything you can do to fix that?'' ``Yes,'' smiled Valentine. ``There is. Once the first processor has sent the message to another, those two can then send messages to two other hosts at the same time. Then there will be four hosts that can send, and so on.'' ``Ah, so you can do the broadcast as a binary tree!'' ``Not really a binary tree -- there are some particular features of our network that we should exploit. The interface cards we have allow each processor to simultaneously send messages to any number of the other processors connected to it. However, the messages don't necessarily arrive at the destinations at the same time -- there is a communication cost involved. In general, we need to take into account the communication costs for each link in our network topologies and plan accordingly to minimize the total time required to do a broadcast.''
Input The input will describe the topology of a network connecting n processors. The first line of the input will be n, the number of processors, such that <= n <= . The rest of the input defines an adjacency matrix, A. The adjacency matrix is square and of size n x n. Each of its entries will be either an integer or the character x. The value of A(i,j) indicates the expense of sending a message directly from node i to node j. A value of x for A(i,j) indicates that a message cannot be sent directly from node i to node j. Note that for a node to send a message to itself does not require network communication, so A(i,i) = for <= i <= n. Also, you may assume that the network is undirected (messages can go in either direction with equal overhead), so that A(i,j) = A(j,i). Thus only the entries on the (strictly) lower triangular portion of A will be supplied. The input to your program will be the lower triangular section of A. That is, the second line of input will contain one entry, A(,). The next line will contain two entries, A(,) and A(,), and so on.
Output Your program should output the minimum communication time required to broadcast a message from the first processor to all the other processors.
Sample Input
Sample Output

题意:题意不好读懂,求什么从1号点到其他各点的最小距离的最大值

1--->2    35
1--->3 30
1--->4 20
1--->5 10 所以就是35…………
x表示两点之间不通
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <vector>
using namespace std;
#define N 1010
#define ll long long
#define INF 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof(a));
vector<vector<int> >Q;
int n,dis[N],vis[N],Map[N][N];
void init()
{
for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
Map[i][j]=i==j?:INF;
}
met(vis,);
}
void dij()
{
for(int i=; i<=n; i++)
{
dis[i]=INF;
}
dis[]=;
for(int i=; i<=n; i++)
{
int ans=INF,k=;
for(int j=; j<=n; j++)
if(!vis[j] && ans>=dis[j])
ans=dis[k=j];
vis[k]=;
for(int j=; j<=n; j++)
if(!vis[j] && dis[j]>dis[k]+Map[k][j])
dis[j]=dis[k]+Map[k][j];
}
}
int main()
{
char m[];
while(scanf("%d",&n)!=EOF)
{
init();
for(int i=; i<=n; i++)
{
for(int j=; j<i; j++)
{
scanf("%s",m);
if(m[]!='x')
Map[i][j]=Map[j][i]=atoi(m);
}
}
dij();
int ans=;
for(int i=; i<=n; i++)
{
ans=max(ans,dis[i]);
}
printf("%d\n",ans);
}
return ;
}
 

(poj)1502 MPI Maelstrom的更多相关文章

  1. 【POJ】1502 MPI Maelstrom

    题目链接:http://poj.org/problem?id=1502 题意:一个处理器给n-1个处理器发送广播,问最短时间.广播时并发,也就是各个路径就大的一方.输入如果是x的话说明两个处理器不能相 ...

  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 1502 MPI Maelstrom(最短路)

    MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4017   Accepted: 2412 Des ...

  4. POJ - 1502 MPI Maelstrom 路径传输Dij+sscanf(字符串转数字)

    MPI Maelstrom BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odys ...

  5. POJ 1502 MPI Maelstrom

    MPI Maelstrom Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) Total ...

  6. POJ 1502 MPI Maelstrom (最短路)

    MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6044   Accepted: 3761 Des ...

  7. POJ 1502 MPI Maelstrom [最短路 Dijkstra]

    传送门 MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5711   Accepted: 3552 ...

  8. POJ 1502 MPI Maelstrom(模板题——Floyd算法)

    题目: BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distri ...

  9. POJ 1502 MPI Maelstrom (Dijkstra)

    题目链接:http://poj.org/problem?id=1502 题意是给你n个点,然后是以下三角的形式输入i j以及权值,x就不算 #include <iostream> #inc ...

随机推荐

  1. String的那点小事儿

    1.== 比较的是什么? 1 package xupengwei.string; 2 /** 3 * @describe: 4 * @author chenmo-xpw 5 * @version 20 ...

  2. Asp.Net Core- 多样性的配置来源

    我们知道,ConfigurationProvider提供将数据源转换为字典的功能,数据源可以分为很多种,比如:物理文件.数据库.内存变量等等.物理文件又包括很多种类型的文件,比如:xml.json等等 ...

  3. [C#源码]VS各版本转换器(支持VS2012,VS2013)

    项目名称:[C#源码]VS各版本转换器(支持VS2012,VS2013) 下载内容: (C#源码)VS各版本转换器 实现功能: 支持vs2003-vs2013的各版本转换,由高到低,由低到高都支持. ...

  4. PHP中各种Hash算法性能比较

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  5. SpecialFolder

            private void button1_Click(object sender, EventArgs e)         {             Environment.Spe ...

  6. ShowcaseView-master

      ShowcaseView.rar

  7. OSI七层模型具体解释

    OSI 七层模型通过七个层次化的结构模型使不同的系统不同的网络之间实现可靠的通讯,因此其最基本的功能就是帮助不同类型的主机实现传输数据 . 完毕中继功能的节点通常称为中继系统.在OSI七层模型中,处于 ...

  8. Android ListView快速定位(二)

    方法二:android:textFilterEnabled="true" + Filter 这个属性在android.widget.AbsListView下,要求adapter必须 ...

  9. 【转】在XCode工程中创建bundle包

    http://www.giser.net/?p=859 Bundle Programming Guide: https://developer.apple.com/library/ios/docume ...

  10. 如何用 PHPMailer 来发送邮件?

    <?php require_once('mantisbt-1.2.15/library/phpmailer/class.phpmailer.php'); $mail= new PHPMailer ...