全WA,样例过,调了必关
查看原帖
全WA,样例过,调了必关
1281479
1234ZSL楼主2025/1/10 21:57
#include <iostream>
using namespace std;
int c[1005][1005], s[1005][1005];
int n, m, r;

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m >> r;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> c[i][j];
			s[i][j] += s[i - 1][j] + s[i][j - 1] + c[i][j] - s[i - 1][j - 1];
		}
	}
	int x = 1, y = 1, x2 = 1, y2 = 1;
	int maxs = -2147483647, maxi = 0, maxj = 0;
	for (; x < n; ++x) {
		for (; y <= m; ++y) {
			x2 = x + r;
			y2 = y + r;
			int f = maxs;
			maxs = max(maxs, s[x2][y2] - s[x - 1][y2] - s[x2][y - 1] + s[x - 1][y - 1]);

			if (maxs > f)
				maxi = x, maxj = y;
		}
	}
	cout << maxi << " " << maxj;
	return 0;
}

2025/1/10 21:57
加载中...