#include<cstdio> #include<vector> #include<algorithm> #include<unordered_map> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int> PII; typedef pair<int,LL> PIL; typedef pair<LL,LL> PLL; typedef vector<PIL> VPIL; typedef vector<PLL> VPLL; typedef vector<LL> VLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<PII> VPII; typedef vector<VPII> VVPII; #define PB push_back #define MP make_pair #define ST first #define ND second #define ALL(c) (c).begin(),(c).end() //#define FOREACH(it,c,i) for(auto it=(c).begin()+(i);it!=(c).end();++it) #define FOREACH(it,c) for(auto it=(c).begin();it!=(c).end();++it) #define SIZE(c) (int)(c).size() LL BP=947449740331179607; VLL pt; LL mx(VPII& t,int xy) { sort(ALL(t)); unordered_map<LL,int> mp; LL hs=0; int pos=0; FOREACH(it,t){ mp[hs]+=it->ST-pos; if(it->ND&1){ hs-=pt[it->ND>>1]; if(hs<0) hs+=BP; } else{ hs+=pt[it->ND>>1]; if(hs>=BP) hs-=BP; } pos=it->ST; } mp[hs]+=xy-pos; int res=0; FOREACH(it,mp) if(it->ND>res) res=it->ND; return res; } int main(){ int i,n,x,y; scanf("%d%d%d",&n,&x,&y); VPII t(2*n),t2(2*n); pt.resize(n+1); pt[0]=1; for(i=0;i<n;++i){ scanf("%d%d%d%d",&t[2*i].ST,&t2[2*i].ST,&t[2*i+1].ST,&t2[2*i+1].ST); pt[i+1]=pt[i]*2; if(pt[i+1]>BP) pt[i+1]-=BP; } for(i=0;i<2*n;++i) t[i].ND=t2[i].ND=i; printf("%lld\n",mx(t,x)*mx(t2,y)); }
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 | #include<cstdio> #include<vector> #include<algorithm> #include<unordered_map> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int> PII; typedef pair<int,LL> PIL; typedef pair<LL,LL> PLL; typedef vector<PIL> VPIL; typedef vector<PLL> VPLL; typedef vector<LL> VLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<PII> VPII; typedef vector<VPII> VVPII; #define PB push_back #define MP make_pair #define ST first #define ND second #define ALL(c) (c).begin(),(c).end() //#define FOREACH(it,c,i) for(auto it=(c).begin()+(i);it!=(c).end();++it) #define FOREACH(it,c) for(auto it=(c).begin();it!=(c).end();++it) #define SIZE(c) (int)(c).size() LL BP=947449740331179607; VLL pt; LL mx(VPII& t,int xy) { sort(ALL(t)); unordered_map<LL,int> mp; LL hs=0; int pos=0; FOREACH(it,t){ mp[hs]+=it->ST-pos; if(it->ND&1){ hs-=pt[it->ND>>1]; if(hs<0) hs+=BP; } else{ hs+=pt[it->ND>>1]; if(hs>=BP) hs-=BP; } pos=it->ST; } mp[hs]+=xy-pos; int res=0; FOREACH(it,mp) if(it->ND>res) res=it->ND; return res; } int main(){ int i,n,x,y; scanf("%d%d%d",&n,&x,&y); VPII t(2*n),t2(2*n); pt.resize(n+1); pt[0]=1; for(i=0;i<n;++i){ scanf("%d%d%d%d",&t[2*i].ST,&t2[2*i].ST,&t[2*i+1].ST,&t2[2*i+1].ST); pt[i+1]=pt[i]*2; if(pt[i+1]>BP) pt[i+1]-=BP; } for(i=0;i<2*n;++i) t[i].ND=t2[i].ND=i; printf("%lld\n",mx(t,x)*mx(t2,y)); } |