3432021-10-18 17:36:21lacitoSivatagcpp11Runtime error 24/40439ms9148 KiB
#include <bits/stdc++.h>
using namespace std;

int desert[501][501];

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
base24/40
1Accepted0/03ms1968 KiB
2Runtime error0/08ms4384 KiB
3Accepted2/21ms2660 KiB
4Accepted2/22ms3340 KiB
5Accepted2/24ms4216 KiB
6Accepted2/24ms4216 KiB
7Accepted2/24ms4232 KiB
8Accepted2/24ms4228 KiB
9Accepted2/22ms2680 KiB
10Accepted2/22ms3364 KiB
11Accepted2/24ms4272 KiB
12Accepted2/24ms4244 KiB
13Accepted2/24ms4248 KiB
14Wrong answer0/24ms4252 KiB
15Accepted1/137ms4896 KiB
16Accepted1/150ms6772 KiB
17Runtime error0/17ms7652 KiB
18Runtime error0/14ms8016 KiB
19Runtime error0/24ms8264 KiB
20Wrong answer0/29ms8488 KiB
21Runtime error0/210ms8772 KiB
22Runtime error0/214ms8888 KiB
23Wrong answer0/28ms9148 KiB
24Time limit exceeded0/2439ms7480 KiB