01矩阵乘法模板

 1 int n;
 2 struct matrix
 3 {
 4     bitset<303>v[303],h[303],temp;
 5     matrix()
 6     {
 7         for(int i=1;i<=n;i++)
 8             v[i].reset(),h[i].reset();
 9         temp.reset();
10     }
11     matrix operator*(const matrix b)const
12     {
13         int i,j,k;
14         matrix ans;
15         for(i=1; i<=n; i++)
16         {
17             for(j=1; j<=n; j++)
18             {
19                 ans.h[i][j]=ans.v[j][i]=((h[i]&b.v[j]).count())&1;
20             }
21         }
22         return ans;
23     }
24     void set()
25     {
26         for(int i=1;i<=n;i++)
27             h[i][i]=v[i][i]=1;
28     }
29 };
 
原文地址:https://www.cnblogs.com/xseventh/p/7388359.html