258032026-03-03 16:28:55abcdSivatagcpp17Accepted 40/4041ms2400 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int maxn=502;
int mat[maxn][maxn];

signed main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m,k,e;cin>>n>>m>>k>>e;
    while(e--){
        int a,b,c,d;cin>>a>>b>>c>>d;
        mat[a][b]++;
        mat[c+1][b]--;
        mat[a][d+1]--;
        mat[c+1][d+1]++;
    }
    for(int k=0;k<2;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                mat[i][j]+=mat[i-1][j]+mat[i][j-1]-mat[i-1][j-1];
    int a=1,b=1,mx=-1;
    for(int i=k;i<=n;i++){
        for(int j=k;j<=m;j++){
            int total=mat[i][j]-mat[i-k][j]-mat[i][j-k]+mat[i-k][j-k];
            if(total>mx){
                mx=total;
                a=i-k+1;
                b=j-k+1;
            }
        }
    }
    cout<<mx<<'\n'<<a<<' '<<b<<'\n';
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms316 KiB
2Accepted0/041ms2356 KiB
3Accepted2/21ms1004 KiB
4Accepted2/22ms1332 KiB
5Accepted2/24ms2356 KiB
6Accepted2/24ms2392 KiB
7Accepted2/24ms2372 KiB
8Accepted2/24ms2356 KiB
9Accepted2/21ms820 KiB
10Accepted2/22ms1252 KiB
11Accepted2/24ms2356 KiB
12Accepted2/23ms2356 KiB
13Accepted2/24ms2400 KiB
14Accepted2/23ms2356 KiB
15Accepted1/137ms1588 KiB
16Accepted1/139ms2008 KiB
17Accepted1/117ms2356 KiB
18Accepted1/132ms2360 KiB
19Accepted2/239ms2356 KiB
20Accepted2/241ms2376 KiB
21Accepted2/239ms2356 KiB
22Accepted2/239ms2396 KiB
23Accepted2/239ms2356 KiB
24Accepted2/239ms2356 KiB