Pagini recente » Cod sursa (job #2149687) | Cod sursa (job #948392) | Cod sursa (job #1246661) | Cod sursa (job #628967) | Cod sursa (job #2870772)
#include <bits/stdc++.h>
#define FILES freopen("royfloyd.in","r",stdin);\
freopen("royfloyd.out","w",stdout);
#define ll long long
#define fastio ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
#define MAX 100
#define pb push_back
#define mp make_pair
#define mod 666013
using namespace std;
int n,a,cost[MAX+5][MAX+5], dp[MAX+5][MAX+5];
int main()
{
fastio
FILES
cin >> n;
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= n; ++j)
{
cin >> cost[i][j];
if(!cost[i][j] && i != j) cost[i][j] = 1e9;
}
}
for(int k = 1;k <= n; ++k)
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= n; ++j)
cost[i][j] = min(cost[i][j],cost[k][j] + cost[i][k]);
}
for(int i = 1; i <= n; ++i,cout << '\n')
for(int j = 1; j <= n; ++j)
cout << (cost[i][j] == 1e9 ? 0 : cost[i][j]) << ' ';
}