NC216159. MatrixEquation
描述
输入描述
The first line has one integer
Then there are lines and each line has integers, the j-th integer of the i-th line denotes
Then there are lines and each line has integers, the j-th integer of the i-th line denotes
,
输出描述
Output the answer module .
示例1
输入:
2 0 1 1 1 1 0 0 1
输出:
2
示例2
输入:
3 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1
输出:
512
示例3
输入:
4 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 1 1 0 1 1 0 1 1 1 1 0 0 1 1 1 1 0
输出:
8
C++(clang++ 11.0.1) 解法, 执行用时: 37ms, 内存消耗: 600K, 提交时间: 2022-11-04 18:17:08
#include <bits/stdc++.h> #define rep(i,l,r) for(int i=(l);i<=(r);++i) #define per(i,r,l) for(int i=(r);i>=(l);--i) using namespace std; const int N=233,P=998244353; int n,x,ans=1,cnt; bitset<N> a[N],b[N],c[N],f[N]; void ins(bitset<N> x){ rep(i,1,n) if(x[i]){ if(f[i][i]) x^=f[i]; else{f[i]=x,--cnt;break;} } } int main(){ scanf("%d",&n); rep(i,1,n) rep(j,1,n) scanf("%d",&x),a[i][j]=x; rep(i,1,n) rep(j,1,n) scanf("%d",&x),b[i][j]=x; rep(j,1,n){ rep(i,1,n) c[i]=a[i],c[i][i]=c[i][i]^b[i][j],f[i]=0;cnt=n; rep(i,1,n) ins(c[i]); rep(i,1,cnt) ans=2ll*ans%P; } printf("%d\n",ans); return 0; }