2592021-03-07 15:30:03varikakasandorSivatagcpp11Wrong answer 0/40308ms20728 KiB
#include <bits/stdc++.h>
using namespace std;

struct rect
{
    int bax,bay,jfx,jfy;
    rect(int bax,int bay,int jfx,int jfy) : bax(bax), bay(bay), jfx(jfx), jfy(jfy) {}
};

int n,m,k,e;
vector<rect> rains;
int best=-1;
int bestx,besty;

int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>m>>k>>e;
    for(int i=1;i<=e;i++)
    {
        int bax,bay,jfx,jfy;
        cin>>bax>>bay>>jfx>>jfy;
        rains.push_back(rect(bax,bay,jfx,jfy));
    }
    for(int i=1;i<=n;i++)
    {
        int xstart=i;
        int xend=i+k-1;
        vector<int> plusminus(m+2,0);
        for(rect r:rains)
        {
            if(max(xstart,r.bax)>min(xend,r.jfx)) continue;
            int cover=min(xend,r.jfx)-max(xstart,r.bax)+1;
            plusminus[r.bay]+=cover;
            plusminus[r.jfy+1]-=cover;
        }
        vector<int> pref(m+1,0);
        for(int j=1;j<=m;j++) pref[j]=pref[j-1]+plusminus[j];
        for(int j=1;j+k-1<=m;j++)
        {
            int curr=pref[j+k-1]-pref[j-1];
            if(curr>best)
            {
                best=curr;
                bestx=i;
                besty=j;
            }
        }
    }
    cout<<best<<endl;
    cout<<bestx<<" "<<besty<<endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/02ms1752 KiB
2Wrong answer0/0263ms7124 KiB
3Wrong answer0/21ms3336 KiB
4Wrong answer0/22ms3344 KiB
5Wrong answer0/23ms3352 KiB
6Wrong answer0/23ms3356 KiB
7Wrong answer0/23ms3360 KiB
8Wrong answer0/22ms3360 KiB
9Wrong answer0/21ms3364 KiB
10Wrong answer0/22ms3368 KiB
11Wrong answer0/23ms3376 KiB
12Wrong answer0/22ms3380 KiB
13Wrong answer0/22ms3380 KiB
14Wrong answer0/23ms3384 KiB
15Wrong answer0/1225ms8664 KiB
16Wrong answer0/1303ms10088 KiB
17Wrong answer0/1136ms8840 KiB
18Wrong answer0/1209ms12140 KiB
19Wrong answer0/2275ms13320 KiB
20Wrong answer0/2252ms14804 KiB
21Wrong answer0/2284ms16284 KiB
22Wrong answer0/2263ms17764 KiB
23Wrong answer0/2308ms19240 KiB
24Wrong answer0/2287ms20728 KiB