2602021-03-07 15:34:44varikakasandorSivatagcpp14Wrong answer 36/40314ms20760 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> perrow(m+1,0);
        vector<int> pref(m+1,0);
        for(int j=1;j<=m;j++) perrow[j]=perrow[j-1]+plusminus[j];
        for(int j=1;j<=m;j++) pref[j]=pref[j-1]+perrow[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
base36/40
1Accepted0/02ms1756 KiB
2Wrong answer0/0264ms7072 KiB
3Accepted2/21ms3356 KiB
4Accepted2/22ms3356 KiB
5Accepted2/23ms3368 KiB
6Accepted2/23ms3364 KiB
7Accepted2/23ms3372 KiB
8Accepted2/23ms3372 KiB
9Accepted2/21ms3368 KiB
10Accepted2/22ms3376 KiB
11Accepted2/23ms3392 KiB
12Accepted2/23ms3388 KiB
13Accepted2/23ms3396 KiB
14Accepted2/23ms3404 KiB
15Accepted1/1221ms8664 KiB
16Accepted1/1289ms10088 KiB
17Accepted1/1133ms8984 KiB
18Accepted1/1208ms12156 KiB
19Accepted2/2314ms13348 KiB
20Wrong answer0/2256ms14820 KiB
21Accepted2/2275ms16316 KiB
22Wrong answer0/2252ms17800 KiB
23Accepted2/2261ms19280 KiB
24Accepted2/2266ms20760 KiB