当前位置:网站首页>Floyed "suggestions collection"
Floyed "suggestions collection"
2022-07-02 15:46:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=405;
const int inf=4000005;
int d1[maxn][maxn],n,m,g[maxn][maxn],d2[maxn][maxn],d3[maxn][maxn];//d1 Shortest path ,d2 The largest side is the smallest ,d3 Min edge Max .
void init()
{
scanf("%d%d%d",&n,&m);
for(int i=1;i<=n;i++)// initial value
for(int j=1;j<=n;j++)
{
if(i==j) g[i][j]=0;
else g[i][j]=inf;
}
for(int i=1;i<=m;i++)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
g[x][y]=z;
g[y][x]=z;
}
}
void floyd()
{
memcpy(d1,g,sizeof(d1));
memcpy(d2,g,sizeof(d2));
memcpy(d3,g,sizeof(d3));
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(d2[i][j]==inf)
d2[i][j]=-inf;
for(int k=1;k<=n;k++)
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
if(d1[i][k]+d1[k][j]<d1[i][j])
d1[i][j]=d1[i][k]+d1[k][j];
int x=min(d2[i][k],d2[k][j]);
d2[i][j]=max(d2[i][j],x);
int t=max(d3[i][k],d3[k][j]);
d3[i][j]=min(d3[i][j],t);
}
}
int main()
{
init();
floyd();
return 0;
}Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/147719.html Link to the original text :https://javaforall.cn
边栏推荐
- 【LeetCode】695-岛屿的最大面积
- 6095. Strong password checker II
- (5) Flink's table API and SQL update mode and Kafka connector case
- 6.12 critical moment of Unified Process Platform
- Leetcode skimming - remove duplicate letters 316 medium
- /bin/ld: 找不到 -llz4
- Redux - detailed explanation
- 士官类学校名录
- 睿智的目标检测23——Pytorch搭建SSD目标检测平台
- 【Leetcode】167-两数之和II -输入有序数组
猜你喜欢

PTA ladder game exercise set l2-001 inter city emergency rescue

Ant group's large-scale map computing system tugraph passed the national evaluation

Loss function and positive and negative sample allocation: Yolo series

Leetcode skimming -- incremental ternary subsequence 334 medium

Two traversal sequences are known to construct binary trees

《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量

Xpt2046 four wire resistive touch screen

密码学基础知识

《大学“电路分析基础”课程实验合集.实验四》丨线性电路特性的研究

Redux - detailed explanation
随机推荐
(4) Flink's table API and SQL table schema
【LeetCode】19-删除链表的倒数第N个结点
locate: 无法执行 stat () `/var/lib/mlocate/mlocate.db‘: 没有那个文件或目录
Fiddler实现手机抓包——入门
数字藏品系统开发(程序开发)丨数字藏品3D建模经济模式系统开发源码
[network security] network asset collection
College entrance examination admission score line crawler
/bin/ld: 找不到 -lxml2
Leetcode skimming -- sum of two integers 371 medium
Moveit 避障路径规划 demo
【LeetCode】200-岛屿数量
Redux——详解
蚂蚁集团大规模图计算系统TuGraph通过国家级评测
[leetcode] 1254 - count the number of closed Islands
Jsp+mysql006 community management system
Review materials for the special topic of analog electronics with all essence: basic amplification circuit knowledge points
Astra: could not open "2bc5/ [email protected] /6“: Failed to set USB interface
已知兩種遍曆序列構造二叉樹
02. After containerization, you must face golang
高考录取分数线爬虫