Pagini recente » Cod sursa (job #2906960) | Cod sursa (job #1479042) | Cod sursa (job #1903214) | Cod sursa (job #258031) | Cod sursa (job #2360892)
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define enter cout << '\n'
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <ll> vl;
typedef vector <pll> vll;
typedef queue <int> qi;
typedef queue <pii> qii;
typedef queue <ll> ql;
typedef queue <pll> qll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 9;
const double EPSILON = 1e-10;
const int NMAX = 100 + 5;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
int n;
int a[NMAX][NMAX];
int main()
{
fin >> n;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
fin >> a[i][j];
for (int k = 1; k <= n; ++k)
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
if (a[i][j] > a[i][k] + a[k][j])
a[i][j] = a[i][k] + a[k][j];
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= n; ++j)
fout << a[i][j] << " ";
fout << '\n';
}
return 0;
}