3262021-10-11 06:38:28rmlanSivatagcpp11Wrong answer 5/40218ms22820 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define ll long long
#define tc int _TC_; cin >> _TC_; while(_TC_--)
using namespace std;

int main(){

    int n,m,k,e;
    cin >> n >> m >> k >> e;
    int c[m][n]={};
    int a[m][n]={};
    for(int i = 0; i < e; i++){
        int fx,fy,ax,ay;
        cin >> ax >> ay >> fx >> fy;
        for(int i = ay-1; i < fy; i++){
            c[i][ax-1]++;
            if(fx < n) c[i][fx]--;
        }

    }

    for(int i = 0; i < m; i++){
        int cu=0;
        for(int j = 0; j < n; j++){
            cu+=c[i][j];
            a[i][j]=cu;
        }
    }
    int pref[m][n]={};
    pref[0][0]=a[0][0];
    for(int i = 1; i < n; i++) pref[0][i]=pref[0][i-1]+a[0][i];
    for(int i = 1; i < m; i++) pref[i][0]=pref[i-1][0]+a[i][0];
    for(int i = 1; i < m; i++){
        for(int j = 1; j < n; j++){
            pref[i][j]=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]+a[i][j];
        }
    }
    pair<int, int> sol;
    int mp=0;
    for(int i = k-1; i < m; i++){
        for(int j = k-1; j < n; j++){
            int p = pref[i][j];
            if(i!=k-1){
                p-=pref[i-k][j];
            }
            if(j != k-1){
                p-=pref[i][j-k];
            }
            if(j!=k-1&&i!=k-1){
                p+=pref[i-k][j-k];
            }
            if(p > mp){
                mp=p;
                sol.fi=j-k+2;
                sol.se=abs(i-(m-1))+1;
            }
        }
    }
    cout << mp << endl<<sol.fi<< " " <<sol.se;

}
SubtaskSumTestVerdictTimeMemory
base5/40
1Wrong answer0/02ms1840 KiB
2Wrong answer0/0218ms9208 KiB
3Wrong answer0/22ms3504 KiB
4Wrong answer0/22ms4760 KiB
5Wrong answer0/26ms9140 KiB
6Wrong answer0/26ms9148 KiB
7Wrong answer0/26ms9148 KiB
8Wrong answer0/26ms9156 KiB
9Wrong answer0/21ms3532 KiB
10Wrong answer0/22ms4792 KiB
11Wrong answer0/24ms9164 KiB
12Wrong answer0/24ms9172 KiB
13Wrong answer0/24ms9172 KiB
14Wrong answer0/24ms9180 KiB
15Wrong answer0/1138ms6960 KiB
16Accepted1/1172ms10020 KiB
17Wrong answer0/179ms12712 KiB
18Wrong answer0/1159ms13960 KiB
19Wrong answer0/2193ms15404 KiB
20Wrong answer0/2203ms16888 KiB
21Accepted2/2193ms18380 KiB
22Wrong answer0/2193ms19856 KiB
23Wrong answer0/2192ms21344 KiB
24Accepted2/2202ms22820 KiB