P3857 [TJOI2008]彩灯

P3857 [TJOI2008]彩灯

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;
typedef pair<int,int>P;
const int inf = 0x7f7f7f7f;
const double INF = 1e16;
const int N = 2e6+10;
const ll mod = 77797;
const double PI = 3.1415926535;
const double eps = 1e-4;

int read(){
    char ch=getchar();int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while('0'<=ch&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int random(int n){
    return (int)(rand()*rand())%n;
}

ll a[55];

void Insert(ll x){
    for(int i = 50;i >= 0;i--){
        if(x&(1ll<<i)){
            if(a[i] == 0) {
                a[i] = x;
                break;
            }else {
                x ^= a[i];
            }
        }
    }
}
int main(){
    int n = read(),m = read();
    for(int i = 1;i <= m;i++){
        ll sum = 0;
        for(int j = 1;j <= n;j++){
            char ch;cin >> ch;
            int x;
            if(ch == 'O') x = 1;
            else x = 0;
            sum = sum*2ll+x;
        }
        Insert(sum);
    }
    int cnt = 0;
    for(int i = 50;i >= 0;i--){
        if(a[i]) cnt++;
    }
    ll ans = 1;
    for(int i = 1;i <= cnt;i++){
        ans = (ans*2ll)%2008ll;
    }
    cout<<ans<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_42868863/article/details/113347343