题目链接: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. 获取最新的中国IP的脚本,给ROS可以使用的脚本

    wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latestecho "/ip firewall address-li ...

  2. Echart、Excel、highcharts、jfreechart对比

      Echart Excel highcharts jfreechart 柱状图 √ √ √ √ 条形图 √ √ √ √ 折线图 √ √ √ √ 面积图 √ √ √ √ 散点图 √ √ √ √ 气泡图 ...

  3. html5滚动页面简单写法

    html5滚动页面简单写法纵向滚动比较简单 直接在外面加个高度 然后overflow-y: auto; 横向比较复杂了外面写两层 最外面一层写个宽度 overflow-x: auto;第二层 写wid ...

  4. Java 并发-Unsafe 相关整理

    https://www.jianshu.com/p/2e5b92d0962e 1. Unsafe 类 Java 不能直接访问操作系统底层,而是通过本地方法来访问.Unsafe 类提供了硬件级别的原子操 ...

  5. FPGA控制RGMII接口PHY芯片基础

    一.前言 网络通信中的PHY芯片接口种类有很多,之前接触过GMII接口的PHY芯片RTL8211EG.但GMII接口数量较多,本文使用RGMII接口的88E1512搭建网络通信系统.这类接口总线位宽小 ...

  6. 【拆分版】Docker-compose构建Kibana单实例,基于7.1.0

    写在前边 今凌晨的时候已经把这整个Docker-compose构建的ELK集群跑起来了,有点没熬住,所以早上起来补文档,今天就上到公司测试服务器上测试了,好开森. 本文内容就是红框的部分,只是启动个K ...

  7. 开发dubbo应用程序(一)入门demo详解

    1.简介: 引用自Dubbo官方文档简介: http://dubbo.apache.org/zh-cn/docs/user/dependencies.html 随着互联网的发展,网站应用的规模不断扩大 ...

  8. Logstash配置文件修改自动加载和指定目录进行启动

    检查配置并启动Logstash,修改后自动加载 指定配置文件目录并启动Logstash

  9. asp.net core web的导入导出excel功能

    这里主要记录下asp.net core web页面上进行导入导出excel的操作. 主要是导入,因为现在使用的很多前端框架(例如kendo ui)本身就有导出的功能. 这里使用到EPPlus.Core ...

  10. C#表达式参数解析算法,N级属性调用,函数值,变量值,常量值

    public static object GetValue(Expression expression) { var names = new Stack<string>(); var ex ...