题目链接:https://vjudge.net/problem/POJ-1502

dijkstra板子题,题目提供下三角情况,不包含正对角线,因为有题意都为0,处理好输入,就是一个很水的题。


 #include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
using namespace std; typedef long long LL;
#define inf (1LL << 30) - 1
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--) const int N = ;
vector<pair<int,int> > G[N];
int val[N];
int vis[N];
int n; int fun(string& x){
int sum = ; rep__(i,,(int)x.length()) sum = sum * + (x[i] - ''); return sum;
} void input(){ string w;
rep(i,,n){
rep__(j,,i){
cin >> w; if(w[] == 'x') continue;
int W = fun(w);
G[i].push_back(make_pair(j,W));
G[j].push_back(make_pair(i,W));
}
}
} int dijkstra(){ if(n == ) return ;
val[] = ;
rep(i,,n) val[i] = inf; rep__(i,,(int)G[].size()) val[G[][i].first] = G[][i].second;
vis[] = true; rep(i,,n){ int x = -;
int v = inf; rep(j,,n){
if(!vis[j] && v > val[j]) v = val[x = j];
} if(x == -) continue;
vis[x] = true; rep__(o,,(int)G[x].size()){
int v = G[x][o].first;
int w = G[x][o].second;
if(!vis[v] && val[v] > val[x] + w)
val[v] = val[x] + w;
}
} int ans = ;
rep(i,,n) ans = max(ans, val[i]); return ans;
} int main(){ ios::sync_with_stdio(false);
cin.tie(); cin >> n;
input();
cout << dijkstra() << endl; getchar();getchar();
return ;
}

kuangbin专题专题四 MPI Maelstrom POJ - 1502的更多相关文章

  1. MPI Maelstrom POJ - 1502 floyd

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> usin ...

  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. 「kuangbin带你飞」专题十四 数论基础

    layout: post title: 「kuangbin带你飞」专题十四 数论基础 author: "luowentaoaa" catalog: true tags: mathj ...

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

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

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

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

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

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

  9. POJ 1502:MPI Maelstrom Dijkstra模板题

    MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6499   Accepted: 4036 Des ...

随机推荐

  1. 大数据-使用Hive导入10G数据

    前言 Hadoop和Hive的环境已经搭建起来了,开始导入数据进行测试.我的数据1G大概对应500W行,MySQL的查询500W行大概3.29秒,用hive同样的查询大概30秒.如果我们把数据增加到1 ...

  2. vue 2.0 及 vue 3.0 rem配置

    vue 2.0 配置 rem 首先先安装postcss-px2rem   (百度可以) https://www.jianshu.com/p/e6476bbc2131 npm install postc ...

  3. Apache的代理服务器的配置 (正向代理 ,反向代理,轮询调度)

    一. 代理服务器的了解1.代理服务器 代理服务器英文全称是Proxy Server,其功能就是代理网络用户去取得网络信息. Squid是一个缓存Internet 数据的软件,其接收用户的下载申请,并自 ...

  4. Oracle_PLSQL导出导入dmp文件

    地址:F:\app\duling\product\11.2.0\dbhome_1\BIN\imp.exe ----------------------------------------------- ...

  5. Java集合详解7:一文搞清楚HashSet,TreeSet与LinkedHashSet的异同

    <Java集合详解系列>是我在完成夯实Java基础篇的系列博客后准备开始写的新系列. 这些文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到我的仓库里查 ...

  6. zabbix php-fpm监控

    #!/bin/bash################################### Zabbix monitoring script## php-fpm:# - anything avail ...

  7. 【Gamma】Scrum Meeting 8

    前言 会议定点:大运村公寓 会议时间:2019/6/7 会议目的:分配任务,准备宣传 一.任务进度 组员 上周任务进度 下阶段任务 大娃 辅助做好引导录屏 优化辅助模型 二娃 撰写会议博客 撰写会议博 ...

  8. LESS是一个CSS预处理器,跨浏览器友好,提供诸如变量,函数, mixins 和操作等功能,可以构建动态CSS

    什么是LESS? LESS是一个CSS预处理器,可以为网站启用可自定义,可管理和可重用的样式表. LESS是一种动态样式表语言,扩展了CSS的功能. LESS也是跨浏览器友好. CSS预处理器是一种脚 ...

  9. Qt相关博客总览

    一.Qt快速入门 Qt快速入门之一:开始学习Qt 与Qt Creator Qt快速入门之二:Qt Creator简介 Qt快速入门之三:Qt程序编译和源码详解 Qt对话框之一:标准对话框 二.Qt窗口 ...

  10. JAVA WEB项目目录结构以及web应用部署的根目录,编译路径和项目根目录的区别

    本文链接:https://blog.csdn.net/l00149133/article/details/78984083 web应用部署的根目录,编译路径和项目的根目录有什么区别? 直接上例子: 你 ...