#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define LL long long
using namespace std;
const int Mod = 998244353, MAXN = 105, MAXM = 2e3 + 5;
int a[MAXN][MAXM], n, m, t;
LL dp[MAXN][MAXN << 1], pre[MAXN], ans, res;
// 考虑优化:会发现,对于 j 和 k,我们不用考虑他们具体的数值,而考虑他们的相对关系即可。
int main() {
// freopen("meal.in", "r", stdin);
// freopen("meal.out", "w", stdout);
scanf("%d%d", &n, &m); ans = 1; t = n - (n / 2) - 1; dp[0][n] = 1;
for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++) scanf("%d", &a[i][j]), pre[i] += a[i][j], pre[i] %= Mod;
for(int i = 1; i <= n; i ++) ans *= (pre[i] + 1), ans %= Mod; ans --;
for(int point = 1; point <= m; point ++) {
for(int i = 1; i <= n; i ++) {
for(int j = 0; j <= (n << 1); j ++) dp[i][j] = dp[i - 1][j]; // 不选
for(int j = 0; j < (n << 1); j ++) dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * (pre[i] - a[i][point])) % Mod; // 不选 point
for(int j = 1; j <= (n << 1); j ++) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] * a[i][point]) % Mod; // 选 point
}
for(int j = n + 1; j <= (n << 1); j ++) res = (res + dp[n][j]) % Mod;
}
ans -= res; ans = (ans % Mod + Mod) % Mod; printf("%lld", ans);
return 0;
}
[CSP-S2019] Emiya 家今天的饭
最新推荐文章于 2023-04-08 08:48:31 发布