Cod sursa(job #1932605)
| Utilizator | Data | 19 martie 2017 22:02:46 | |
|---|---|---|---|
| Problema | Floyd-Warshall/Roy-Floyd | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std;
int n,A[110][110];
int main() {
ifstream cin ("royfloyd.in");
ofstream cout ("royfloyd.out");
cin>>n;
for (int i=1; i<=n; i++){
for (int j=1; j<=n; j++) cin>>A[i][j];
}
for (int k=1; k<=n; k++){
for (int i=1; i<=n; i++){
for (int j=1; j<=n; j++){
A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
}
}
}
for (int i=1; i<=n; i++){
for (int j=1; j<=n; j++) cout<<A[i][j]<<" ";
cout<<"\n";
}
return 0;
}
