记录编号 571577 评测结果 AAAAAAAAAAAAAAAAAAAAAAAAA
题目名称 [CSP 2019S]Emiya家今天的饭 最终得分 100
用户昵称 Gravatar冷月星云 是否通过 通过
代码语言 C++ 运行时间 0.856 s
提交时间 2022-05-30 18:17:17 内存使用 3.31 MiB
显示代码纯文本
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long

using namespace std;

ll a[105][2005];
ll s[105][2005],f[105][205],g[105][105],ans;
const ll MOD = 998244353;
int main(){
	freopen("2019meal.in","r",stdin);
	freopen("2019meal.out","w",stdout);
	ll n , m;
	cin >> n >> m;
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= m;j++){
			cin >> a[i][j];
			s[i][0] = (s[i][0] + a[i][j]) % MOD;
		}
	for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) s[i][j] = (s[i][0] - a[i][j] + MOD) % MOD;
	g[0][0] = 1;
	for(int i = 1;i <= n;i++)
		for(int j = 0;j <= n;j++)
			g[i][j] = (g[i - 1][j] + s[i][0] * g[i - 1][j - 1] % MOD) % MOD;
	for(int i = 1;i <= n;i++)
		ans = (ans + g[n][i]) % MOD;
	for(int l = 1;l <= m;l++){
		memset(f,0,sizeof(f));
		f[0][n] = 1;
		for(int i = 1;i <= n;i++)
			for(int j = n - i;j <= n + i;j++)
				f[i][j] = (f[i-1][j] + a[i][l] * f[i - 1][j - 1] % MOD + s[i][l] * f[i - 1][j + 1] % MOD) % MOD;
		for(int i = 1;i <= n;i++)
			ans = (ans - f[n][n+i] + MOD) % MOD;
	}
	cout << ans;
	return 0;
}