为什么爆零?
查看原帖
为什么爆零?
1206388
pengjingfei267楼主2024/11/10 20:53
#include <bits/stdc++.h>
using namespace std;
int a[105][105], s[105][105];

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			char c;
			cin >> c;
			a[i][j] = c - '0';
			s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
		}
	}
	int ans = 2e9;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int x = 1; x <= n; x++) {
				for (int y = 1; y <= n; y++) {
					if (s[x][y] - s[i][y] - s[x][j] + s[i][j] >= k) {
						ans = min(ans, s[x][y] - s[i][y] - s[x][j] + s[i][j]);
					}
				}
			}
		}
	}
	if (ans == 2e9) {
		cout << 0;
	} else {
		cout << ans;
	}
	return 0;
}

明明我有AC的测试点,为什么还会0分?

2024/11/10 20:53
加载中...