萌新求助线性基

P3857 [TJOI2008] 彩灯

fzhfzh @ 2021-04-17 22:30:53

RT,#1#10WA

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
long long n,m,d[70],ans,t[60];
string a[60];
int add(long long x){
    for(int i=62;i>=0;i--){
        if(x&(1ll<<i)){
            if(d[i])x^=d[i];
            else{
                d[i]=x;
                return 114514;
            }
        }
    }
    return 1919810;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i];
        for(int j=0;j<n;j++){
            t[i]+=(1ll<<(n-i))*(a[i][j]=='O'?1:0);
        }
    }
    for(int i=1;i<=m;i++){
        if(add(t[i])==114514)ans++;
    }
    cout<<(1ll<<ans)%2008;
    return 0;
}

by FutaRimeWoawaSete @ 2021-04-17 22:48:58

@fzhfzh 把

t[i]+=(1ll<<(n-i))*(a[i][j]=='O'?1:0);

换成

t[i]+=(1ll<<(j))*(a[i][j]=='O'?1:0);

或者

t[i]+=(1ll<<( n - j))*(a[i][j]=='O'?1:0);

这里当成自然的二进制位数就可以了。


by fzhfzh @ 2021-04-17 23:01:29

啊我SB了...里面的循环应该是j。。。


by fzhfzh @ 2021-04-17 23:01:40

@FutaRimeWoawaSete thk


|