3292021-10-11 19:49:01rmlanSivatagcpp11Wrong answer 7/40225ms28740 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))+1;
            }
        }
    }
    cout << mp << endl<<sol.fi<< " " <<sol.se;

}
SubtaskSumTestVerdictTimeMemory
base7/40
1Wrong answer0/02ms1848 KiB
2Wrong answer0/0225ms15120 KiB
3Wrong answer0/22ms3764 KiB
4Wrong answer0/23ms6272 KiB
5Wrong answer0/28ms15048 KiB
6Wrong answer0/28ms15128 KiB
7Wrong answer0/28ms15048 KiB
8Wrong answer0/28ms15080 KiB
9Wrong answer0/21ms3776 KiB
10Wrong answer0/23ms6304 KiB
11Wrong answer0/28ms15156 KiB
12Wrong answer0/28ms15076 KiB
13Wrong answer0/28ms15052 KiB
14Wrong answer0/28ms15128 KiB
15Wrong answer0/1149ms9016 KiB
16Accepted1/1187ms13820 KiB
17Wrong answer0/190ms18592 KiB
18Wrong answer0/1173ms19756 KiB
19Wrong answer0/2199ms21328 KiB
20Accepted2/2216ms22800 KiB
21Accepted2/2201ms24296 KiB
22Wrong answer0/2197ms25772 KiB
23Wrong answer0/2208ms27264 KiB
24Accepted2/2211ms28740 KiB