3302021-10-11 20:31:15rmlanSivatagcpp11Elfogadva 40/40219ms15680 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=i-k+2;
            }
        }
    }
    cout << mp << endl<<sol.fi<< " " <<sol.se;

}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/02ms1832 KiB
2Elfogadva0/0202ms15100 KiB
3Elfogadva2/21ms3740 KiB
4Elfogadva2/23ms6252 KiB
5Elfogadva2/28ms15008 KiB
6Elfogadva2/28ms15012 KiB
7Elfogadva2/28ms15012 KiB
8Elfogadva2/28ms15020 KiB
9Elfogadva2/21ms3768 KiB
10Elfogadva2/23ms6276 KiB
11Elfogadva2/28ms15028 KiB
12Elfogadva2/28ms15036 KiB
13Elfogadva2/28ms15044 KiB
14Elfogadva2/29ms15048 KiB
15Elfogadva1/1160ms8136 KiB
16Elfogadva1/1182ms11392 KiB
17Elfogadva1/1101ms15680 KiB
18Elfogadva1/1195ms15672 KiB
19Elfogadva2/2215ms15680 KiB
20Elfogadva2/2219ms15668 KiB
21Elfogadva2/2215ms15680 KiB
22Elfogadva2/2214ms15676 KiB
23Elfogadva2/2216ms15668 KiB
24Elfogadva2/2202ms15680 KiB