POJ 1502 MPI MaeIstrom ( 裸最短路 || atoi系统函数 )
题意 : 给出 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系统函数 )的更多相关文章
- POJ 1502 MPI Maelstrom(最短路)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4017 Accepted: 2412 Des ...
- 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 ...
- POJ 1502 MPI Maelstrom (最短路)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6044 Accepted: 3761 Des ...
- POJ 1502 MPI Maelstrom [最短路 Dijkstra]
传送门 MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5711 Accepted: 3552 ...
- POJ 1502 MPI Maelstrom
MPI Maelstrom Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) Total ...
- POJ 1502 MPI Maelstrom (Dijkstra)
题目链接:http://poj.org/problem?id=1502 题意是给你n个点,然后是以下三角的形式输入i j以及权值,x就不算 #include <iostream> #inc ...
- (简单) POJ 1502 MPI Maelstrom,Dijkstra。
Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odysse ...
- POJ 1502 MPI Maelstrom(模板题——Floyd算法)
题目: BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distri ...
- POJ - 1502 MPI Maelstrom 路径传输Dij+sscanf(字符串转数字)
MPI Maelstrom BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odys ...
随机推荐
- nginx坑记录
问题1: 配置解析过程使用ngx_cycle->pool申请内存保存配置,结果造成野指针. 背景:需求开发过程,有一些结构需要在配置解析阶段保存,然后可以动态修改.看原来的代码配置解析都是使用c ...
- 转发与重定向(forward与redirect)
顾名思义,转发是内部跳转:重定向是重新定向后跳转. 区别: 地址栏显示上: forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL的响应内容读取过来,然后把这些内容再发给浏览器. ...
- 多进程---multiprocessing/threading/
一.多进程:multiprocessing模块 多用于处理CPU密集型任务 多线程 多用于IO密集型任务 Input Ouput 举例: import multiprocessing,threadin ...
- KETTLE——(三)数据输出
数据输出和数据输入基本差不多,KETTLE本身支持的数据输出方式也特别多,还是以数据库输出为例. 打开表输出的界面,简单介绍一下其功能: 就这个界面,如果不勾选[指定数据库字段],KETTLE ...
- nodejs 格式化 Date() 为yyyy-MM-dd HH:mm:ss 格式
===============2019-11-25更新======== 推荐:更实用完美解决时间格式化的 组件 monent 官网地址:http://momentjs.cn/ ============ ...
- Babel编译:动态计算的属性名
ES2015允许使用表达式作为属性名. 编译前: const HELLO = 'hello'; let dog = { [HELLO](){ console.log('hello'); } } 编译后 ...
- 【MM系列】SAP ABAP BAPI 和 RFC 的区别
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP BAPI 和 ...
- Java反序列化漏洞整理
Fastjson 反序列化 CVE-- Fastjson 利用版本范围为 Fastjson 及之前的版本 Struts2 S2-, S2-, S2-, S2-, S2-, S2-, S2-, S2-, ...
- data plugin for vs2019
Reporting Service projects for VS 2019https://marketplace.visualstudio.com/items?itemName=ProBITools ...
- Java类和对象的内存分配
类的加载时机: 1.创建对象 2.调用类的静态成员 3.加载子类 类在实例化后的内存分配 1.每次创建对象时,都需要进行加载和创建2个操作: ① 先去判断需要的类是否已经加载,如果已经加载了,则无需再 ...