1 条题解
-
0
C++ :
#include<bits/stdc++.h> using namespace std; const int N=510; int d[N][N]; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { cin>>d[i][j]; } } int res=0; for(int k=n;k>1;k--) { for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { d[i][j]=min(d[i][j],d[i][k]+d[k][j]); if(i>=k&&j>=k) { res+=d[i][j]; } } } } cout<<res; return 0; }
- 1
信息
- ID
- 731
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者