Pagini recente » Cod sursa (job #948173) | Cod sursa (job #1600450) | Cod sursa (job #374110) | Cod sursa (job #1320423) | Cod sursa (job #3266559)
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 102;
const int INF = 1e9;
int n,dp[NMAX][NMAX];
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
template<typename T>
void minSelf(T &a, T b){
a = min(a, b);
}
int main() {
fin >> n;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
fin >> dp[i][j];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
for(int k = 1; k <= n; k++){
minSelf(dp[i][j], dp[i][k] + dp[k][j]);
}
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
fout << dp[i][j] << " ";
}
fout << "\n";
}
return 0;
}