3462021-10-18 17:42:27lacitoSivatagcpp11Accepted 40/4048ms20988 KiB
#include <bits/stdc++.h>
using namespace std;

long long desert[502][502];

int main() {
  ios::sync_with_stdio(false);
  int n, m, k, e;
  cin >> n >> m >> k >> e;
  for (int i = 0; i < e; i++){
    int bax, bay, jfx, jfy;
    cin >> bax >> bay >> jfx >> jfy;
    desert[bax][bay]++;
    desert[bax][jfy+1]--;
    desert[jfx+1][bay]--;
    desert[jfx+1][jfy+1]++;
  }
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      desert[i][j] += desert[i][j-1] + desert[i-1][j] - desert[i-1][j-1];
    }
  }
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      desert[i][j] += desert[i][j-1] + desert[i-1][j] - desert[i-1][j-1];
    }
  }
  long long max = -1, sorszi, sorszj;
  for (int i = k; i <= n; i++){
    for (int j = k; j <= m; j++){
      if (max < desert[i][j] + desert[i-k][j-k] - desert[i][j-k] - desert[i-k][j]){
        max = desert[i][j] + desert[i-k][j-k] - desert[i][j-k] - desert[i-k][j];
        sorszi = i - k + 1;
        sorszj = j - k + 1;
      }
    }
  }
  cout << max << "\n" << sorszi << " " << sorszj;
  return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms1940 KiB
2Accepted0/041ms7328 KiB
3Accepted2/21ms4196 KiB
4Accepted2/23ms5296 KiB
5Accepted2/24ms7312 KiB
6Accepted2/24ms7320 KiB
7Accepted2/24ms7316 KiB
8Accepted2/24ms7324 KiB
9Accepted2/22ms4224 KiB
10Accepted2/22ms5324 KiB
11Accepted2/24ms7336 KiB
12Accepted2/24ms7344 KiB
13Accepted2/24ms7344 KiB
14Accepted2/24ms7352 KiB
15Accepted1/139ms7212 KiB
16Accepted1/141ms9544 KiB
17Accepted1/121ms10816 KiB
18Accepted1/135ms11988 KiB
19Accepted2/245ms13496 KiB
20Accepted2/245ms15048 KiB
21Accepted2/243ms16456 KiB
22Accepted2/243ms18016 KiB
23Accepted2/248ms19500 KiB
24Accepted2/241ms20988 KiB