WA86分求助!
查看原帖
WA86分求助!
378951
farfarqwq楼主2022/11/30 11:16

RT,蒟蒻的这发提交WA了,而之前的这发提交AC,已确认两份代码一样,目测是数据加强,求捉虫QWQ。

代码:

#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1005, mod = 998244353;
int r[N][N], u[N][N], C[N][N];
char a[N][N];
signed main() {
// 	freopen("plant.in", "r", stdin);
// 	freopen("plant.out", "w", stdout);
	int t, id, n, m, c, f;
	scanf("%d%d", &t, &id);
	while (t--) {
		scanf("%d%d%d%d", &n, &m, &c, &f);
		for (int i = 1; i <= n; i++) {
			scanf("%s", a[i] + 1);
			for (int j = m; j; j--) {
				r[i][j] = u[i][j] = C[i][j] = 0;
				if (a[i][j] == '0') {
					r[i][j] = r[i][j + 1] + 1;
					u[i][j] = u[i - 1][j] + max(0, r[i - 1][j] - 1);
				}
			}
		}
		long long ans1 = 0, ans2 = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++) {
				if (a[i][j] == '0') {
					C[i][j] = max(r[i][j] - 1, 0) * u[i - 1][j];
					ans1 += C[i][j];
					C[i][j] += C[i - 1][j];
					ans2 += C[i - 1][j];
					// cout << i << ' ' << j << ' ' << C[i][j] << ' ' << r[i][j] << ' ' << u[i][j] << '\n';
				}
			}
		printf("%lld %lld\n", ans1 % mod * c, ans2 % mod * f);
	}
	return 0;
}
2022/11/30 11:16
加载中...