bitset 优化
#include <bits/stdc++.h>
using namespace std;
int n;
bitset<110> a[110];
int main()
{
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++){
int x;
cin>>x;
a[i][j]=x;
}
for (int j = 1; j <= n; j++)//注意j循环在i循环外
for (int i = 1; i <= n; i++)
if (a[i][j])
a[i] |= a[j];//bitset也挺好写的
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
putchar(a[i][j] + '0'), putchar(' ');
putchar('\n');
}
return 0;
}
over~