当前位置:网站首页>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
边栏推荐
- /bin/ld: 找不到 -lxslt
- The task cannot be submitted after the installation of flick is completed
- 【LeetCode】344-反转字符串
- (Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
- Cultural scores of summer college entrance examination
- 蚂蚁集团大规模图计算系统TuGraph通过国家级评测
- PTA 天梯赛习题集 L2-001 城市间紧急救援
- [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)
- Strings and arrays
- College entrance examination admission score line climbing
猜你喜欢
Finally, I understand the event loop, synchronous / asynchronous, micro task / macro task, and operation mechanism in JS (with test questions attached)
The outline dimension function application of small motherboard
Leetcode skimming -- sum of two integers 371 medium
已知两种遍历序列构造二叉树
Party History Documentary theme public welfare digital cultural and creative products officially launched
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
Basic knowledge of cryptography
Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
Ant group's large-scale map computing system tugraph passed the national evaluation
随机推荐
【LeetCode】1140-石子游戏II
XPT2046 四线电阻式触摸屏
Wechat Alipay account system and payment interface business process
【LeetCode】695-岛屿的最大面积
【idea】推荐一个idea翻译插件:Translation「建议收藏」
6095. Strong password checker II
【LeetCode】486-预测赢家
《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究
Leetcode skimming -- incremental ternary subsequence 334 medium
使用 percona 工具给 MySQL 表加字段中断后该如何操作
[experience cloud] how to get the metadata of experience cloud in vscode
Leetcode skimming -- verifying the preorder serialization of binary tree # 331 # medium
For the problem that Folium map cannot be displayed, the temporary solution is as follows
【LeetCode】200-岛屿数量
Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network
Soul torture, what is AQS???
Jsp+mysql006 community management system
【LeetCode】417-太平洋大西洋水流问题
02. After containerization, you must face golang
[leetcode] 1162 map analysis