其他分享
首页 > 其他分享> > 传递闭包

传递闭包

作者:互联网

传递闭包模板

 

#include<iostream>
#define maxn 10007
using namespace std;
int a[maxn], dis[107][107], n, m;
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> dis[i][j];
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                dis[i][j] = dis[i][j] | (dis[i][k] & dis[k][j]);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
            cout << dis[i][j] << ' ';
        cout << endl;
    }
    return 0;
}

 

标签:闭包,int,cin,传递,maxn,tie,107
来源: https://www.cnblogs.com/xqk0225/p/16217318.html