[TJOI2008]彩灯

线性基裸题,求最大线性无关组。
注意:1ll<<i

#include <cstdio>
int n,m;
const int mod=2008;
long long b[64];
void insert(long long x) {
    for(int i=62; ~i; i--) {
        if((x>>i)&1) {
            if(b[i]) x^=b[i];
            else {
                b[i]=x;
                return;
            }
        }
    }
}
char s[70];
long long ans;
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1; i<=m; i++) {
        scanf("%s",s);
        long long tp=0;
        for(int j=0; j<n; j++) {
            if(s[j]=='O') tp+=(1ll<<j);
        }
        insert(tp);
    }
    for(int i=0; i<62; i++) if(b[i])ans++;
    printf("%d",(1ll<<ans)%mod);
}
我是咸鱼。转载博客请征得博主同意Orz
原文地址:https://www.cnblogs.com/sdfzhsz/p/9261390.html