比赛 2024暑假C班集训A 评测结果 AAAAAAAAAA
题目名称 牧场的安排 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 0.032 s
代码语言 C++ 内存使用 3.54 MiB
提交时间 2024-07-10 09:20:46
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (1<<13)+10;
const ll mod = 1e8;

ll read(){
    ll x = 0,f = 1;char c = getchar();
    for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
    for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
    return x * f;
}


int n,m;
int a[15];
ll f[15][N];

int main(){
    freopen("cowfood.in","r",stdin);
    freopen("cowfood.out","w",stdout);
    n = read(),m = read();
    for(int i = 1;i <= n;i++)
        for(int j = 1;j <= m;j++)a[i] = (a[i] << 1) + read();
    f[0][0] = 1;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j < (1<<m);j++){
            if((a[i] | j) != a[i] || ((j << 1) & j) != 0 || ((j >> 1) & j) != 0)continue;
            for(int k = 0;k < (1<<m);k++){
                if((a[i-1] | k) != a[i-1] || (j & k) != 0 || ((k << 1) & k) != 0 || ((k >> 1) & k) != 0)continue;
                (f[i][j] += f[i-1][k]) %= mod;
            }
        }
    }
    ll ans = 0;
    for(int i = 0;i < (1<<m);i++)
        if((i | a[n]) == a[n])(ans += f[n][i]) %= mod;
    printf("%lld\n",ans % mod);
    
    
    return 0;
    
}