题意 : 给出 N 个点,各个点之间的路径长度用给出的下三角矩阵表示,上上角矩阵和下三角矩阵是一样的,主对角线的元素都是 0 代表自己到达自己不用花费,现在问你从 1 到 N 的最短路,矩阵的 x 代表点间无法互相到达

分析 : 最短路模板…… 就是在输入的时候需要将字符串变成整数、自己写也可以,也可以使用 atoi(char *)函数,其作用是将字符串数组变成整数,复杂度为 O(n)

#include<bits/stdc++.h>
using namespace std;
;
const int INF  = 0x3f3f3f3f;
typedef pair<int, int> HeapNode;

struct EDGE{ int v, nxt, w; };
int Head[maxn], Dis[maxn];
EDGE Edge[maxn*maxn];
int N, cnt;
inline void init()
{
    ; i<=N; i++)
        Head[i]=-, Dis[i]=INF;
    cnt = ;
}

inline void AddEdge(int from, int to, int weight)
{
    Edge[cnt].v = to;
    Edge[cnt].w = weight;
    Edge[cnt].nxt = Head[from];
    Head[from] = cnt++;
}

int Dijkstra(int st)
{
    priority_queue< HeapNode, vector<HeapNode>, greater<HeapNode> > Heap;
    Dis[st] = ;
    Heap.push(make_pair(, st));
    while(!Heap.empty()){
        pair<int, int> T = Heap.top(); Heap.pop();
        if(T.first != Dis[T.second]) continue;
        ; i=Edge[i].nxt){
            int Eiv = Edge[i].v;
            if(Dis[Eiv] > Dis[T.second] + Edge[i].w){
                Dis[Eiv] = Dis[T.second] + Edge[i].w;
                Heap.push(make_pair(Dis[Eiv], Eiv));
            }
        }
    }
    ;
    ; i<=N; i++)
        ret = max(ret, Dis[i]);
    return ret;
}
];
int main(void)
{

    while(~scanf("%d", &N)){
        init();
        ; i<=N; i++){
            ; j<i; j++){
                scanf("%s", Digit);
                ] != 'x'){
                    int weight = atoi(Digit);
                    AddEdge(i, j, weight);
                    AddEdge(j, i, weight);
                }
            }
        }
        printf());
    }

    ;
}

POJ 1502 MPI MaeIstrom ( 裸最短路 || atoi系统函数 )的更多相关文章

  1. POJ 1502 MPI Maelstrom(最短路)

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

  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 [最短路 Dijkstra]

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

  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 (Dijkstra)

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

  7. (简单) POJ 1502 MPI Maelstrom,Dijkstra。

    Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odysse ...

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

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

随机推荐

  1. python中有哪些类型的布尔值是False?

    1.None 2. False 3.所有的值为零的数 4."" 5.[] 6.() 7.{}

  2. Application.Restore不起作用了

    http://www.myexception.cn/delphi/695243.html Application.Restore不起作用了窗体上只有一个Button和一个Timer(1秒计时)代码如下 ...

  3. 类TreeMap

    TreeMap类 import java.util.Set; import java.util.TreeMap; public class IntegerDemo { public static vo ...

  4. Good teachers,they inspire you, they entertain you,and you end up learning a ton even when you don't know it.

    pardon. v. 原谅.抱歉.再说一次 honourable.adj.值得钦佩的 specification.n.规格.标准 amongst.prep.在...中 gallon.n.加仑 comp ...

  5. yolov--7--解决报错:/bin/sh: 1: nvcc: not found make: *** [obj/convolutional_kernels.o] Error 127

    1.配置darknet配置darknet出现错误: qhy@qhy-desktop:~/darknet$ make cleanqhy@qhy-desktop:~/darknet$ make……gcc ...

  6. Java基础/阿里巴巴Java开发手册

    阿里巴巴Java开发手册 序号 文档名及下载地址 1 阿里巴巴Java开发手册v1.2.0 2 <阿里巴巴Java开发手册>(终极版) 为什么阿里巴巴禁止工程师直接使用日志系统(Log4j ...

  7. Ubuntu操作系统的总结操作

    一.Ubuntu系统环境变量 Ubuntu Linux系统环境变量配置文件分为两种:系统级文件和用户级文件 1.系统级文件: /etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件 ...

  8. BZOJ4753: [Jsoi2016]最佳团体(分数规划+树上背包)

    BZOJ4753: [Jsoi2016]最佳团体(分数规划+树上背包) 标签:题解 阅读体验 BZOJ题目链接 洛谷题目链接 具体实现 看到分数和最值,考虑分数规划 我们要求的是一个\(\dfrac{ ...

  9. python实现一个简单的网络聊天程序

    一.Linux Socket 1.Linux Socke基本上就是BSD Socket(伯克利套接字) 伯克利套接字的应用编程接口(API)是采用C语言的进程间通信的库,经常用在计算机网络间的通信.B ...

  10. GitHub上更新原有的项目代码(二)

    转载自:https://blog.csdn.net/dayewandou/article/details/79175783 项目上传了,现在又写了一些内容想要跟新到项目上去,怎么更新呢? 首先进入项目 ...