parent
ab52d533f4
commit
de7f48ecb7
@ -0,0 +1,27 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in new issue