Cod sursa(job #3227584)
| Utilizator | Data | 2 mai 2024 08:41:26 | |
|---|---|---|---|
| Problema | Floyd-Warshall/Roy-Floyd | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, i, j, k, a[105][105];
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.in");
int main()
{
fin >> n >> m;
while(m)
{
fin >> x >> y;
a[x][y] = 1;
m --;
}
for(k = 1; k <= n; k ++)
for(i = 1; i <= n; i ++)
for(j = 1; j <= n; j ++)
if(a[i][j] == 0)
a[i][j] = a[i][k] * a[k][j];
for(i = 1; i <= n; i ++)
{
for(j = 1; j <= n; j ++)
fout << a[i][j] << " ";
fout << "\n";
}
return 0;
}
