#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
int mod[2]={1000000000+7,1000000000+9};
int pot[2][500010];
pair<int,int> tab[2][500010];
pair<int,pair<int,int>> pom[1000010];
int pref[2][1000010];
map<pair<int,int>,int> mapa;
long long sol(int n,int t,int m)
{
int w=0,i,j;
j=1;
for(i=1;i<=n;i++,j+=2)
{
if(tab[t][i].fi>tab[t][i].se)
swap(tab[t][i].fi,tab[t][i].se);
pom[j]={tab[t][i].fi,{pot[0][i],pot[1][i]}};
pom[j+1]={tab[t][i].se,{mod[0]-pot[0][i],mod[1]-pot[1][i]}};
}
n*=2;
sort(pom+1,pom+n+1);
pom[n+1].fi=m+pom[1].fi;
for(i=1;i<=n;i++)
{
for(int k:{0,1})
{
pref[k][i]=(pref[k][i-1]+pom[i].se.fi)%mod[k];
swap(pom[i].se.fi,pom[i].se.se);
}
}
mapa.clear();
for(i=1;i<=n;i++)
{
mapa[{pref[0][i],pref[1][i]}]+=pom[i+1].fi-pom[i].fi;
w=max(w,mapa[{pref[0][i],pref[1][i]}]);
//cerr<<pom[i].fi<<" "<<pref[0][i]<<" "<<w<<"\n";
}
return w;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,X,Y,i;
cin>>n>>X>>Y;
for(i=1;i<=n;i++)
{
cin>>tab[0][i].fi>>tab[1][i].fi>>tab[0][i].se>>tab[1][i].se;
}
for(int k:{0,1})
{
pot[k][0]=1;
for(i=1;i<=n;i++)
pot[k][i]=(2*pot[k][i-1])%mod[k];
}
//cerr<<sol(n,0,X)<<" "<<sol(n,1,Y)<<"\n";
cout<<sol(n,0,X)*sol(n,1,Y)<<"\n";
return 0;
}
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 | #include<bits/stdc++.h> #define fi first #define se second #define pb push_back using namespace std; int mod[2]={1000000000+7,1000000000+9}; int pot[2][500010]; pair<int,int> tab[2][500010]; pair<int,pair<int,int>> pom[1000010]; int pref[2][1000010]; map<pair<int,int>,int> mapa; long long sol(int n,int t,int m) { int w=0,i,j; j=1; for(i=1;i<=n;i++,j+=2) { if(tab[t][i].fi>tab[t][i].se) swap(tab[t][i].fi,tab[t][i].se); pom[j]={tab[t][i].fi,{pot[0][i],pot[1][i]}}; pom[j+1]={tab[t][i].se,{mod[0]-pot[0][i],mod[1]-pot[1][i]}}; } n*=2; sort(pom+1,pom+n+1); pom[n+1].fi=m+pom[1].fi; for(i=1;i<=n;i++) { for(int k:{0,1}) { pref[k][i]=(pref[k][i-1]+pom[i].se.fi)%mod[k]; swap(pom[i].se.fi,pom[i].se.se); } } mapa.clear(); for(i=1;i<=n;i++) { mapa[{pref[0][i],pref[1][i]}]+=pom[i+1].fi-pom[i].fi; w=max(w,mapa[{pref[0][i],pref[1][i]}]); //cerr<<pom[i].fi<<" "<<pref[0][i]<<" "<<w<<"\n"; } return w; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,X,Y,i; cin>>n>>X>>Y; for(i=1;i<=n;i++) { cin>>tab[0][i].fi>>tab[1][i].fi>>tab[0][i].se>>tab[1][i].se; } for(int k:{0,1}) { pot[k][0]=1; for(i=1;i<=n;i++) pot[k][i]=(2*pot[k][i-1])%mod[k]; } //cerr<<sol(n,0,X)<<" "<<sol(n,1,Y)<<"\n"; cout<<sol(n,0,X)*sol(n,1,Y)<<"\n"; return 0; } |
English