当前位置:网站首页>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
边栏推荐
- 6091. Divide the array so that the maximum difference is K
- 怎样从微信返回的json字符串中截取某个key的值?
- 制作p12证书[通俗易懂]
- folium,确诊和密接轨迹上图
- (4) Flink's table API and SQL table schema
- Pyinstaller打包exe附带图片的方法
- [leetcode] 417 - Pacific Atlantic current problem
- 高考分数线爬取
- Why does the system convert the temp environment variable to a short file name?
- (万字精华知识总结)Shell脚本编程基础知识
猜你喜欢

Xpt2046 four wire resistive touch screen

03. Preliminary use of golang

Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals

已知两种遍历序列构造二叉树
![[leetcode] 1254 - count the number of closed Islands](/img/84/f888ae0e164951cd9623fb3bf4a984.png)
[leetcode] 1254 - count the number of closed Islands

PHP static members

Review materials for the special topic of analog electronics with all essence: basic amplification circuit knowledge points

Leetcode question brushing - parity linked list 328 medium

2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)

密码学基础知识
随机推荐
Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals
《大学“电路分析基础”课程实验合集.实验四》丨线性电路特性的研究
02. After containerization, you must face golang
【LeetCode】977-有序數組的平方
PostgresSQL 流复制 主备切换 主库无读写宕机场景
/bin/ld: 找不到 -lssl
2303. 计算应缴税款总额
目标检测—利用labelimg制作自己的深度学习目标检测数据集
[leetcode] 486 predict winners
[development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)
[leetcode] 977 - carré du tableau ordonné
6096. Success logarithm of spells and potions
【idea】推荐一个idea翻译插件:Translation「建议收藏」
睿智的目标检测23——Pytorch搭建SSD目标检测平台
蚂蚁集团大规模图计算系统TuGraph通过国家级评测
floyed「建议收藏」
爱可可AI前沿推介(7.2)
[leetcode] 167 - sum of two numbers II - enter an ordered array
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
Golang MD5 encryption and MD5 salt value encryption