标签:ret oid 题目 problems mes http mat ons lang
题目::https://pintia.cn/problem-sets/15/problems/717
#include<iostream>
using namespace std;
const int N = 505 ;
const int MAX = 1000000000 ;
int n,m,s,d;
int mat[N][N] , cost[N][N] ;
void floyd(){
for(int k = 0 ; k < n ; k++)
for(int i = 0 ; i < n ; i ++)
for(int j = 0 ; j < n ; j++){
if((mat[i][j] > mat[i][k] + mat[k][j])
|| (mat[i][j] == mat[i][k] + mat[k][j]) &&
(cost[i][j] > cost[i][k] + cost[k][j]))
{
mat[i][j] = mat[i][k] + mat[k][j] ;
cost[i][j] = cost[i][k] + cost[k][j] ;
}
}
}
int main(){
cin>>n>>m>>s>>d ;
for(int i =0 ;i < n ;i++)
for(int j = 0 ; j < n ; j ++){
if(i != j) mat[i][j] = MAX ;
}
for(int i = 0 ; i < m ; i++){
int a,b,c,d;
cin>>a>>b>>c>>d ;
mat[a][b] = mat[b][a] = c ;
cost[a][b] = cost[b][a] = d ;
}
floyd();
cout<<mat[s][d]<<‘ ‘<<cost[s][d];
return 0;
}
标签:ret oid 题目 problems mes http mat ons lang
原文地址:https://www.cnblogs.com/lkfsblogs/p/13127545.html