交警队长
2023-09-20 17:46:57
发布于:浙江
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int MOD = 998244353;
const int N=105, M=2005;
int n, m, a[N][M], hm;
int sum[N], f[N][2*N];
ll ans=1;
void init() {
for(int i=1; i<=n; i++)
for(int j=0; j<=2*n; j++)
f[i][j] = 0;
}
int main() {
cin>>n>>m;
for(int i=1; i<=n; i++) {
sum[i] = 0;
for(int j=1; j<=m; j++) {
cin>>a[i][j];
sum[i] = (sum[i]+1LL*a[i][j])%MOD;
}
ans = (ans * (sum[i]+1))%MOD;
}
for(int c=1; c<=m; c++) {
init();
f[0][n] = 1;
for(int i=1; i<=n; i++)
for(int j=0; j<=2n; j++) {
ll tmp = f[i-1][j];
if(j>0 && a[i][c])
tmp = (tmp + 1LL * a[i][c] * f[i-1][j-1])%MOD;
int delta = sum[i] - a[i][c];
if(j<2n && delta)
tmp = (tmp + 1LL * delta *f[i-1][j+1])%MOD;
f[i][j] = tmp;
if(i==n && j>n)
ans = (ans-f[i][j])%MOD;
}
}
cout<<(ans-1+MOD)%MOD<<endl;
return 0;
}
这里空空如也
有帮助,赞一个