You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
778 B

#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, m, c;
int a[N][N], s[N][N];
int mx = INT_MIN;
int main() {
cin >> n >> m >> c;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j]; // 构建二维前缀和
}
int x, y;
for (int i = c; i <= n; i++) // 边长为c
for (int j = c; j <= m; j++) {
if (s[i][j] - s[i - c][j] - s[i][j - c] + s[i - c][j - c] > mx) {
mx = s[i][j] + s[i - c][j - c] - s[i - c][j] - s[i][j - c];
x = i - c + 1;
y = j - c + 1;
}
}
printf("%d %d", x, y);
return 0;
}