#include <bits/stdc++.h> using namespace std; pair <int,int> PO[1000005],PI[1000005]; int k,n,X,Y,ax,ay,bx,by; int m,wa,mp; int pop[1000005],ko[1000005],w[1000005]; int odw[500005]; int wyn, wynik; long long r,o; int main() { ios_base::sync_with_stdio(0); cin>>n>>X>>Y; PO[0]={0,0}; PO[1]={Y,0}; PI[0]={0,0}; PI[1]={X,0}; k=2; for(int i=1;i<=n;i++) { cin>>ax>>ay>>bx>>by; PO[k]={ay,i}; PO[k+1]={by,i}; PI[k]={ax,i}; PI[k+1]={bx,i}; k+=2; } sort(PO,PO+k); sort(PI,PI+k); for(int i=0;i<k;i++) { m=PI[i].first; wa=PI[i].second; pop[i]=i-1; ko[i]=i+1; if(i==0) w[i]=-1; else w[i]=m-PI[i-1].first; } for(int i=0;i<k;i++) { //cout<<PI[i].first<<' '<<PI[i].second<<' '<<pop[i]<<' '<<ko[i]<<' '<<w[i]<<endl; m=PI[i].first; wa=PI[i].second; if(odw[wa]==0&&i!=k-1) { odw[wa]=i; } else { mp=odw[wa]; wynik=max(wynik,w[ko[mp]]); //cout<<" +"<<w[ko[mp]]<<' '; if(pop[i]!=mp) { wynik=max(wynik,w[i]); //cout<<" +"<<w[i]<<' '; w[ko[mp]]=w[mp]; } else { w[ko[i]]=w[ko[i]]+w[mp]; } ko[pop[mp]]=ko[mp]; pop[ko[mp]]=pop[mp]; ko[pop[i]]=ko[i]; pop[ko[i]]=pop[i]; } // cout<<endl; } for(int i=0;i<k;i++) { m=PO[i].first; wa=PO[i].second; pop[i]=i-1; ko[i]=i+1; if(i==0) w[i]=-1; else w[i]=m-PO[i-1].first; odw[wa]=0; } for(int i=0;i<k;i++) { //cout<<PO[i].first<<' '<<PO[i].second<<' '<<pop[i]<<' '<<ko[i]<<' '<<w[i]<<endl; m=PO[i].first; wa=PO[i].second; if(odw[wa]==0&&i!=k-1) { odw[wa]=i; } else { mp=odw[wa]; wyn=max(wyn,w[ko[mp]]); // cout<<" +"<<w[ko[mp]]<<' '; if(pop[i]!=mp) { wyn=max(wyn,w[i]); //cout<<" +"<<w[i]<<' '; w[ko[mp]]=w[mp]; } else { w[ko[i]]=w[ko[i]]+w[mp]; } ko[pop[mp]]=ko[mp]; pop[ko[mp]]=pop[mp]; ko[pop[i]]=ko[i]; pop[ko[i]]=pop[i]; } //cout<<endl; } r=wyn; o=wynik*r; cout<<o; } /* 3 11 5 2 1 8 6 7 1 10 5 3 1 5 2 */
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | #include <bits/stdc++.h> using namespace std; pair <int,int> PO[1000005],PI[1000005]; int k,n,X,Y,ax,ay,bx,by; int m,wa,mp; int pop[1000005],ko[1000005],w[1000005]; int odw[500005]; int wyn, wynik; long long r,o; int main() { ios_base::sync_with_stdio(0); cin>>n>>X>>Y; PO[0]={0,0}; PO[1]={Y,0}; PI[0]={0,0}; PI[1]={X,0}; k=2; for(int i=1;i<=n;i++) { cin>>ax>>ay>>bx>>by; PO[k]={ay,i}; PO[k+1]={by,i}; PI[k]={ax,i}; PI[k+1]={bx,i}; k+=2; } sort(PO,PO+k); sort(PI,PI+k); for(int i=0;i<k;i++) { m=PI[i].first; wa=PI[i].second; pop[i]=i-1; ko[i]=i+1; if(i==0) w[i]=-1; else w[i]=m-PI[i-1].first; } for(int i=0;i<k;i++) { //cout<<PI[i].first<<' '<<PI[i].second<<' '<<pop[i]<<' '<<ko[i]<<' '<<w[i]<<endl; m=PI[i].first; wa=PI[i].second; if(odw[wa]==0&&i!=k-1) { odw[wa]=i; } else { mp=odw[wa]; wynik=max(wynik,w[ko[mp]]); //cout<<" +"<<w[ko[mp]]<<' '; if(pop[i]!=mp) { wynik=max(wynik,w[i]); //cout<<" +"<<w[i]<<' '; w[ko[mp]]=w[mp]; } else { w[ko[i]]=w[ko[i]]+w[mp]; } ko[pop[mp]]=ko[mp]; pop[ko[mp]]=pop[mp]; ko[pop[i]]=ko[i]; pop[ko[i]]=pop[i]; } // cout<<endl; } for(int i=0;i<k;i++) { m=PO[i].first; wa=PO[i].second; pop[i]=i-1; ko[i]=i+1; if(i==0) w[i]=-1; else w[i]=m-PO[i-1].first; odw[wa]=0; } for(int i=0;i<k;i++) { //cout<<PO[i].first<<' '<<PO[i].second<<' '<<pop[i]<<' '<<ko[i]<<' '<<w[i]<<endl; m=PO[i].first; wa=PO[i].second; if(odw[wa]==0&&i!=k-1) { odw[wa]=i; } else { mp=odw[wa]; wyn=max(wyn,w[ko[mp]]); // cout<<" +"<<w[ko[mp]]<<' '; if(pop[i]!=mp) { wyn=max(wyn,w[i]); //cout<<" +"<<w[i]<<' '; w[ko[mp]]=w[mp]; } else { w[ko[i]]=w[ko[i]]+w[mp]; } ko[pop[mp]]=ko[mp]; pop[ko[mp]]=pop[mp]; ko[pop[i]]=ko[i]; pop[ko[i]]=pop[i]; } //cout<<endl; } r=wyn; o=wynik*r; cout<<o; } /* 3 11 5 2 1 8 6 7 1 10 5 3 1 5 2 */ |