Pagini recente » Cod sursa (job #1020259) | Cod sursa (job #862441) | Cod sursa (job #3151528) | Cod sursa (job #223575) | Cod sursa (job #3192644)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
const int nax = 1e5+5;
const int64_t inf = 1e17;
int n,m;
int64_t len;
struct cladire{ int h,e,l; } sus[nax],jos[nax];
int a[101][101];
int main(){
fin>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++){
fin>>a[i][j];
if(!a[i][j]) a[i][j]=1e9;
}
for(int z=1;z<=n;z++)
for(int x=1;x<=n;x++)
for(int y=1;y<=n;y++)
a[x][y]=min(a[x][y],a[x][z]+a[z][y]);
for(int i=1;i<=n;i++,fout<<'\n')
for(int j=1;j<=n;j++)
if(i==j) fout<<0<<' ';
else
fout<<a[i][j]<<' ';
return 0;
}