3282021-10-11 19:47:55rmlanSivatagcpp11Wrong answer 3/40232ms21292 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(){

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

    }

    for(ll i = 0; i < m; i++){
        ll cu=0;
        for(ll j = 0; j < n; j++){
            cu+=c[i][j];
            a[i][j]=cu;
        }
    }
    ll pref[m][n]={};
    pref[0][0]=a[0][0];
    for(ll i = 1; i < n; i++) pref[0][i]=pref[0][i-1]+a[0][i];
    for(ll i = 1; i < m; i++) pref[i][0]=pref[i-1][0]+a[i][0];
    for(ll i = 1; i < m; i++){
        for(ll 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<ll, ll> sol;
    ll mp=0;
    for(ll i = k-1; i < m; i++){
        for(ll j = k-1; j < n; j++){
            ll 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));
            }
        }
    }
    cout << mp << endl<<sol.fi<< " " <<sol.se;

}
SubtaskSumTestVerdictTimeMemory
base3/40
1Accepted0/02ms1800 KiB
2Accepted0/0204ms15116 KiB
3Wrong answer0/22ms3752 KiB
4Wrong answer0/24ms6268 KiB
5Wrong answer0/28ms15012 KiB
6Wrong answer0/28ms15020 KiB
7Wrong answer0/27ms15020 KiB
8Wrong answer0/27ms15024 KiB
9Wrong answer0/21ms3780 KiB
10Wrong answer0/23ms6288 KiB
11Wrong answer0/28ms15036 KiB
12Wrong answer0/28ms15040 KiB
13Wrong answer0/28ms15044 KiB
14Wrong answer0/27ms15052 KiB
15Wrong answer0/1143ms8984 KiB
16Wrong answer0/1178ms13784 KiB
17Wrong answer0/185ms18580 KiB
18Accepted1/1165ms19724 KiB
19Wrong answer0/2216ms21292 KiB
20Wrong answer0/2206ms21272 KiB
21Wrong answer0/2203ms21280 KiB
22Accepted2/2212ms21280 KiB
23Wrong answer0/2232ms21280 KiB
24Wrong answer0/2214ms21284 KiB