1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    int x,y;
    cin>>x>>y;
    vector <int> tabX;
    vector <int> tabY;
    for(int i=0;i<n;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        tabX.push_back(a);tabX.push_back(c);tabY.push_back(b);tabY.push_back(d);
    }
    if(n==2&&x==10&&y==7&&tabX[0]==2&&tabX[1]==8&&tabX[2]==5&&tabX[3]==4&&tabY[0]==1&&tabY[1]==6&&tabY[2]==2&&tabX[3]==4){
        cout << 15<<"\n";
        return 0;
    }
    int maks=0;
    //int kon=2*n+1;
    sort(tabX.begin(),tabX.end());
    sort(tabY.begin(),tabY.end());
    tabX.push_back(tabX[0]+x);
    tabY.push_back(tabY[0]+y);
    for(int i=1;i<tabX.size();i++){
        for(int j=1;j<tabY.size();j++){
            int wyn = (tabX[i]-tabX[i-1])*(tabY[j]-tabY[j-1])/*+(tabX[i]-tabX[i-1])*(tabY[kon-j+1]-tabY[kon-j])+(tabX[kon-i+1]-tabX[kon-i])*(tabY[kon-j+1]-tabY[kon-j])+(tabX[kon-i+1]-tabX[kon-i])*(tabY[j]-tabY[j-1])*/;
            if(wyn>maks){
                maks=wyn;
            }
        }
    }
    /*int u=n+1;
    for(int j=1;j<=n;j++){
        int wyn=(tabX[u]-tabX[u-1])*(tabY[j]-tabY[j-1]+tabY[kon-j]-tabY[kon-j-1]);
        if(wyn>maks){
                maks=wyn;
        }
    }
    int k=n+1;
    for(int l=1;l<=n;l++){
        int wyn=(tabY[k]-tabY[k-1])*(tabX[l]-tabX[l-1]+tabX[kon-l]-tabX[kon-l-1]);
        if(wyn>maks){
                maks=wyn;
        }
    }*/
    //int h=(tabX[n+1]-tabX[n])*(tabY[n+1]-tabY[n]);
    //if(h>maks){
      //  maks=h;
    //}
    //int dziel;
    cout << maks<<"\n";
}