3442021-10-18 17:38:58lacitoSivatagcpp11Wrong answer 36/4054ms19048 KiB
#include <bits/stdc++.h>
using namespace std;

int 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];
    }
  }
  int 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
base36/40
1Accepted0/02ms1836 KiB
2Wrong answer0/048ms5412 KiB
3Accepted2/21ms3744 KiB
4Accepted2/22ms4328 KiB
5Accepted2/24ms5332 KiB
6Accepted2/24ms5308 KiB
7Accepted2/24ms5312 KiB
8Accepted2/24ms5436 KiB
9Accepted2/21ms3796 KiB
10Accepted2/22ms4344 KiB
11Accepted2/24ms5432 KiB
12Accepted2/24ms5436 KiB
13Accepted2/24ms5456 KiB
14Accepted2/24ms5364 KiB
15Accepted1/139ms6108 KiB
16Accepted1/139ms7972 KiB
17Accepted1/120ms8944 KiB
18Accepted1/137ms10136 KiB
19Accepted2/241ms11616 KiB
20Wrong answer0/245ms13104 KiB
21Accepted2/254ms14584 KiB
22Wrong answer0/245ms16072 KiB
23Accepted2/243ms17552 KiB
24Accepted2/246ms19048 KiB