每一个2*2矩阵的异或值为1
任意一个矩阵的左上左下右上右下的值异或值为1/0
且当这个矩阵由奇数个2*2矩阵组成时为0,偶数个为1
题目给出了\(k\)个条件,可以发现,确定了左上角和右下角后,我们就可以知道左下角和右上角的关系(相等或不等)
我们枚举(1,1)这个点,这样,就有\(k\)组关系式。
建出一个二分图,当某两个点已经被联通且边的异或值与将要连的边权值相等,那么便无解
用带权并查集维护连通块
最后答案就是\(2^{连通块个数-1}\)
#include
#define int long long
using namespace std;
const int N = 1e5 + 5, MOD = 1e9;
int n, m, k;
int x[N], y[N], z[N];
int fa[N << 1], g[N << 1];
inline int read () {
int tot = 0, f = 1; char c = getchar ();
while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar (); }
while (c >= '0' && c <= '9') { tot = tot * 10 + c - '0'; c = getchar (); }
return t