MPI Maelstrom---poj1502 (shortest path template)

Source: Internet
Author: User

Title Link:http://poj.org/problem?id=1502

Test instructions: What is the minimum time required to request from processor 1 to other processors;

The input is the lower triangle, if x means a "I" "J" cannot be contacted directly;

#include <cstdio>#include<cstring>#include<cstdlib>#include<iostream>#include<algorithm>using namespacestd;#defineN 110#defineINF 0XFFFFFFFintMaps[n][n], N;voidFloyd () { for(intk=1; k<=n; k++)         for(intI=1; i<=n; i++)             for(intj=1; j<=n; J + +) {Maps[i][j]=min (maps[i][k]+Maps[k][j], maps[i][j]); }}intMain () { while(SCANF ("%d", &n)! =EOF) {memset (maps,0,sizeof(maps));  for(intI=2; i<=n; i++)        {             for(intj=1; j<i; J + +)            {                Chars[Ten]; scanf ("%s", s); if(s[0]=='x') Maps[i][j]= Maps[j][i] =INF; Else                {                    intnum =0;  for(intk=0; S[K]; k++) Num= num*Ten+ s[k]-'0'; MAPS[I][J]= Maps[j][i] =num;        }}} Floyd (); intmax=0;  for(intI=1; i<=n; i++) Max= Max (max, maps[1][i]); printf ("%d\n", Max); }    return 0;}
View Code

MPI Maelstrom---poj1502 (shortest path template)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.