异或方程组高斯消元模板

inline void solve (int n) {
    for (int i = 1, top = 1; i <= n; i ++, top ++) {
        int cur = 0;
        for (int j = top; j <= n; j ++)
            if (mat[j][i]) {
                cur = j;
                break;
            }
        if (!cur) {
            top --;
            ans = 2ll * ans % MOD;
            continue;
        }
        if (cur != top) swap(mat[cur], mat[top]);
        for (int j = 1; j <= n; j ++)
            if (top != j && mat[j][i]) mat[j] ^= mat[top];
    }
}
posted @ 2022-10-05 11:14  duoluoluo  阅读(32)  评论(0)    收藏  举报