Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, m, x, y;
- bool a[128][128];
- void read () {
- cin >> n >> m;
- while (m --) {
- cin >> x >> y;
- a[x][y] = 1;
- }
- }
- void RW () {
- 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] == 0)
- a[i][j] = a[i][k] * a[k][j];
- }
- void print () {
- for (int i = 1; i <= n; ++i, cout << '\n')
- for (int j = 1; j <= n; ++j)
- cout << a[i][j] << " ";
- }
- int main() {
- read();
- RW();
- print();
- return 0;
- }
Add Comment
Please, Sign In to add comment