257992026-03-03 16:11:32abcdSivatagcpp17Runtime error 24/4097ms2584 KiB
#include <bits/stdc++.h>
using namespace std;

const int maxn=501;
int mat[maxn][maxn],pref[maxn][maxn];

int main(){
    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=0;
    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
base24/40
1Accepted0/01ms316 KiB
2Runtime error0/014ms1756 KiB
3Accepted2/21ms564 KiB
4Accepted2/22ms820 KiB
5Accepted2/23ms1396 KiB
6Accepted2/23ms1388 KiB
7Accepted2/23ms1180 KiB
8Accepted2/23ms1332 KiB
9Accepted2/21ms564 KiB
10Accepted2/22ms840 KiB
11Accepted2/23ms1348 KiB
12Accepted2/23ms1524 KiB
13Accepted2/23ms1336 KiB
14Wrong answer0/23ms1332 KiB
15Accepted1/196ms2396 KiB
16Accepted1/197ms2584 KiB
17Runtime error0/19ms1588 KiB
18Runtime error0/117ms1588 KiB
19Runtime error0/28ms1588 KiB
20Runtime error0/22ms1400 KiB
21Runtime error0/237ms2100 KiB
22Runtime error0/24ms1332 KiB
23Runtime error0/223ms1864 KiB
24Runtime error0/225ms1880 KiB