题目大意:求点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;

}

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

  1. POJ 1502 MPI Maelstrom( Spfa, Floyd, Dijkstra)

    题目大意: 给你 1到n ,  n个计算机进行数据传输, 问从1为起点传输到所有点的最短时间是多少, 其实就是算 1 到所有点的时间中最长的那个点. 然后是数据 给你一个n 代表有n个点, 然后给你一 ...

  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: 6044   Accepted: 3761 Des ...

  4. POJ 1502 MPI Maelstrom(最短路)

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

  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 路径传输Dij+sscanf(字符串转数字)

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

  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. Java之instanceof

    class Base{     int x = 1;     static int y = 2;     String name(){         return "mother" ...

  2. Java、Node.js、PHP还是.Net? 无论你选谁,我都能教你一招!

    七夕如期而至,不该来的终究还是来了.再傲娇的单身贵族恐怕也难免在今天会感觉一丝丝的空虚.还好你关注了我,因为接下来我准备了三大招教你一个人…..也可以优雅地过七夕. 招式一:移形幻影,无中生有 七夕当 ...

  3. haml scss转换编写html css的前期工作

    http://www.w3cplus.com/sassguide/install.html 先下载ruby $ gem sources $ gem sources --remove https://r ...

  4. mybatis 原理研究

    1. mybatis 是使用JDBC来实现的, 所以需要我们首先了解JDBC 的查询 ①加载JDBC驱动 ②建立并获取数据库连接 ③设置sql语句的传递参数 ④执行sql语句并获得结果 ⑤对结果进行转 ...

  5. vector的基本用法

    #include<iostream> #include<vector> #include<algorithm> using namespace std; int m ...

  6. readystatechange

    // alternative to DOMContentLoaded document.onreadystatechange = function () { if (document.readySta ...

  7. Linux网络管理及基础设置

    一.网络管理 1 临时配置网络(ip,网关,dns) 用ifconfig命令设定网卡的IP地址: ens33网卡的IP地址为192.168.16.154, ifconfig ens33 192.168 ...

  8. Codeforces Round #277.5 (Div. 2)-B. BerSU Ball

    http://codeforces.com/problemset/problem/489/B B. BerSU Ball time limit per test 1 second memory lim ...

  9. Linux文件系统概述二

    VFS-目录项对象(dentry) 每个文件除了有一个索引节点 inode 数据结构外,还有一个目录项 dentry 数据结构 dentry 结构代表的是逻辑意义上的文件,描述的是文件逻辑上的属性,目 ...

  10. OpenCV2:第十一章 图像转换

    一.简介 二.例子 #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #inclu ...