​linkkk​​ 题意:

2020ICPC济南站 A . Matrix Equation (高斯消元)_算法

思路:
2020ICPC济南站 A . Matrix Equation (高斯消元)_#define_02
2020ICPC济南站 A . Matrix Equation (高斯消元)_i++_03
对于2020ICPC济南站 A . Matrix Equation (高斯消元)_算法_04
2020ICPC济南站 A . Matrix Equation (高斯消元)_c++_05
2020ICPC济南站 A . Matrix Equation (高斯消元)_c++_06的加法和取余2020ICPC济南站 A . Matrix Equation (高斯消元)_算法_07相当于异或。
式子变成了
2020ICPC济南站 A . Matrix Equation (高斯消元)_i++_08
相当于解一个异或线性方程组,对于2020ICPC济南站 A . Matrix Equation (高斯消元)_算法_04中,是相互独立的。最后2020ICPC济南站 A . Matrix Equation (高斯消元)_#define_10就是答案。
如果2020ICPC济南站 A . Matrix Equation (高斯消元)_算法_11,则2020ICPC济南站 A . Matrix Equation (高斯消元)_#define_12,这样右侧的结果位都是2020ICPC济南站 A . Matrix Equation (高斯消元)_i++_13
2020ICPC济南站 A . Matrix Equation (高斯消元)_算法_14,则2020ICPC济南站 A . Matrix Equation (高斯消元)_#define_15

代码:

// Problem: Matrix Equation
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/10662/A
// Memory Limit: 524288 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll>PLL;
typedef pair<int, int>PII;
typedef pair<double, double>PDD;
typedef pair<string,string>PSS;
#define I_int ll
inline ll read(){ll x = 0, f = 1;char ch = getchar();while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}return x * f;}

inline void write(ll x){if (x < 0) x = ~x + 1, putchar('-');if (x > 9) write(x / 10);putchar(x % 10 + '0');}

#define read read()
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)

ll ksm(ll a, ll b,ll mod){ll res = 1;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int maxn=2010;
const double pi = acos(-1);
ll n,m=31;
ll a[210][210],g[210];
int A[210][210],B[210][210];
const int mod=998244353;
int Gauss(int n,int m)
{
int r, c;
for(r = 0, c = 0; c < n; c++)
{
int t = -1;
for(int i = r; i < m; i++)
{
if(a[i][c])
{
t = i;
break;
}
}
if(t==-1) continue;

for(int i = c; i < n; i++)///交换
{
swap(a[t][i], a[r][i]);
}

for(int i = r + 1; i < m; i++)
{
if(a[i][c])
for(int j = c; j <n; j++)
{
a[i][j] = a[i][j] ^ a[r][j];
}
}

r++;
}
return n-r;
}
void solve()
{
n=read;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
A[i][j]=read;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
B[i][j]=read;
ll cnt=0;
for(int j=0;j<n;j++){

for(int i=0;i<n;i++){
for(int k=0;k<n;k++){
a[i][k]=A[i][k];
}
a[i][n]=0;
if(A[i][i]==B[i][j]) a[i][i]=0;
else a[i][i]=1;
}
ll tot=Gauss(n,n);
if(tot<0){
puts("0");
return ;
}
else{
cnt+=tot;

}
}
cout<<ksm(2,cnt,mod)<<endl;

}

int main()
{
int _;_=1;
while(_--) solve();
return 0;
}