#include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <string> #include <bitset> #include <vector> #include <set> #include <map> #include <queue> #include <algorithm> #include <sstream> #include <stack> #include <iomanip> #include <assert.h> using namespace std; #define pb push_back #define mp make_pair typedef pair<int,int> pii; typedef long long ll; typedef double ld; typedef vector<int> vi; #define fi first #define se second #define fe first #define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);} #define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);} #define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);} #define es(x,e) (int e=fst[x];e;e=nxt[e]) #define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e]) #define SZ 2234567 #define y1 yy1 #define y2 yy2 #define ln lln int n; const int M=1048576; int P[SZ],Q[SZ],lls[SZ],lln,tg[SZ]; pii sg[SZ]; #define LS(w) (lower_bound(lls+1,lls+1+lln,w)-lls) int ls[SZ],rs[SZ]; pii operator + (pii a,pii b) { if(a.fi!=b.fi) return max(a,b); return pii(a.fi,a.se+b.se); } void pd(int x) { if(!tg[x]) return; sg[x].fi+=tg[x]; if(x<=M) tg[x+x]+=tg[x], tg[x+x+1]+=tg[x]; tg[x]=0; } void upd(int x) { pd(x+x); pd(x+x+1); sg[x]=sg[x+x]+sg[x+x+1]; } void edt(int x,int l,int r,int v) { if(r<ls[x]||rs[x]<l) return; pd(x); if(l<=ls[x]&&rs[x]<=r) { tg[x]+=v; return; } edt(x+x,l,r,v); edt(x+x+1,l,r,v); upd(x); } ll work(int m,int*p,int*q) { map<int,vector<int>> ps; ps[0].clear(); lln=0; lls[++lln]=0; lls[++lln]=m; for(int i=1;i<=n;++i) { if(p[i]>q[i]) swap(p[i],q[i]); ps[p[i]].pb(i); ps[q[i]].pb(-i); lls[++lln]=p[i],lls[++lln]=q[i]; } sort(lls+1,lls+1+lln); lln=unique(lls+1,lls+1+lln)-lls-1; for(int i=1;i<=n;++i) P[i]=LS(p[i]),Q[i]=LS(q[i])-1; memset(sg,0,sizeof sg); memset(tg,0,sizeof tg); for(int i=0;i<M;++i) ls[i+M]=rs[i+M]=i; for(int i=1;i<lln;++i) sg[i+M]=pii(1e9,lls[i+1]-lls[i]); for(int i=M-1;i>=1;--i) sg[i]=sg[i+i]+sg[i+i+1], ls[i]=ls[i+i], rs[i]=rs[i+i+1]; //total length of max for(int i=1;i<=n;++i) edt(1,P[i],Q[i],-1); int ans=0; for(auto &u:ps) { for(auto r:u.se) { int x=r; if(r>0) edt(1,P[x],Q[x],2); else x=-x, edt(1,P[x],Q[x],-2); } ans=max(ans,sg[1].se); } return ans; } int x,y,x1[SZ],y1[SZ],x2[SZ],y2[SZ]; int main() { scanf("%d%d%d",&n,&x,&y); for(int i=1;i<=n;++i) scanf("%d%d%d%d",x1+i,y1+i,x2+i,y2+i); printf("%lld\n",work(x,x1,x2)*work(y,y1,y2)); }
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 | #include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <string> #include <bitset> #include <vector> #include <set> #include <map> #include <queue> #include <algorithm> #include <sstream> #include <stack> #include <iomanip> #include <assert.h> using namespace std; #define pb push_back #define mp make_pair typedef pair<int,int> pii; typedef long long ll; typedef double ld; typedef vector<int> vi; #define fi first #define se second #define fe first #define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);} #define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);} #define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);} #define es(x,e) (int e=fst[x];e;e=nxt[e]) #define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e]) #define SZ 2234567 #define y1 yy1 #define y2 yy2 #define ln lln int n; const int M=1048576; int P[SZ],Q[SZ],lls[SZ],lln,tg[SZ]; pii sg[SZ]; #define LS(w) (lower_bound(lls+1,lls+1+lln,w)-lls) int ls[SZ],rs[SZ]; pii operator + (pii a,pii b) { if(a.fi!=b.fi) return max(a,b); return pii(a.fi,a.se+b.se); } void pd(int x) { if(!tg[x]) return; sg[x].fi+=tg[x]; if(x<=M) tg[x+x]+=tg[x], tg[x+x+1]+=tg[x]; tg[x]=0; } void upd(int x) { pd(x+x); pd(x+x+1); sg[x]=sg[x+x]+sg[x+x+1]; } void edt(int x,int l,int r,int v) { if(r<ls[x]||rs[x]<l) return; pd(x); if(l<=ls[x]&&rs[x]<=r) { tg[x]+=v; return; } edt(x+x,l,r,v); edt(x+x+1,l,r,v); upd(x); } ll work(int m,int*p,int*q) { map<int,vector<int>> ps; ps[0].clear(); lln=0; lls[++lln]=0; lls[++lln]=m; for(int i=1;i<=n;++i) { if(p[i]>q[i]) swap(p[i],q[i]); ps[p[i]].pb(i); ps[q[i]].pb(-i); lls[++lln]=p[i],lls[++lln]=q[i]; } sort(lls+1,lls+1+lln); lln=unique(lls+1,lls+1+lln)-lls-1; for(int i=1;i<=n;++i) P[i]=LS(p[i]),Q[i]=LS(q[i])-1; memset(sg,0,sizeof sg); memset(tg,0,sizeof tg); for(int i=0;i<M;++i) ls[i+M]=rs[i+M]=i; for(int i=1;i<lln;++i) sg[i+M]=pii(1e9,lls[i+1]-lls[i]); for(int i=M-1;i>=1;--i) sg[i]=sg[i+i]+sg[i+i+1], ls[i]=ls[i+i], rs[i]=rs[i+i+1]; //total length of max for(int i=1;i<=n;++i) edt(1,P[i],Q[i],-1); int ans=0; for(auto &u:ps) { for(auto r:u.se) { int x=r; if(r>0) edt(1,P[x],Q[x],2); else x=-x, edt(1,P[x],Q[x],-2); } ans=max(ans,sg[1].se); } return ans; } int x,y,x1[SZ],y1[SZ],x2[SZ],y2[SZ]; int main() { scanf("%d%d%d",&n,&x,&y); for(int i=1;i<=n;++i) scanf("%d%d%d%d",x1+i,y1+i,x2+i,y2+i); printf("%lld\n",work(x,x1,x2)*work(y,y1,y2)); } |