#include<bits/stdc++.h> using namespace std; const long long mod=99999999999995509; long long pot[1000005]; map<long long,int> mapa; vector<long long> v; vector<pair<long long,long long>> v1; vector<pair<long long,long long>> v2; int maks1=0,maks2; void pre() { pot[0]=1; for(int x=1;x<=1e6;x++) pot[x]=(pot[x-1]*5)%mod; } void znajdz(long long c) { long long last=0,act=0; v1.push_back(make_pair(c,0)); for(auto x:v1) { if(x.first-last>0) { if(mapa[act]==0) v.push_back(act); mapa[act]+=(x.first-last); maks1=max(maks1,mapa[act]); } last=x.first; act=(act-x.second+mod)%mod; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); pre(); int a; long long b,c,d,e,f,g; cin>>a>>b>>c; for(int x=0;x<a;x++) { cin>>d>>e>>f>>g; v1.push_back(make_pair(min(d,f),pot[x])); v1.push_back(make_pair(max(d,f),-pot[x])); v2.push_back(make_pair(min(e,g),pot[x])); v2.push_back(make_pair(max(e,g),-pot[x])); } sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end()); znajdz(b); maks2=maks1; maks1=0; v1=v2; for(auto x:v) mapa[x]=0; znajdz(c); long long maks=maks2; cout<<maks*maks1; 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 | #include<bits/stdc++.h> using namespace std; const long long mod=99999999999995509; long long pot[1000005]; map<long long,int> mapa; vector<long long> v; vector<pair<long long,long long>> v1; vector<pair<long long,long long>> v2; int maks1=0,maks2; void pre() { pot[0]=1; for(int x=1;x<=1e6;x++) pot[x]=(pot[x-1]*5)%mod; } void znajdz(long long c) { long long last=0,act=0; v1.push_back(make_pair(c,0)); for(auto x:v1) { if(x.first-last>0) { if(mapa[act]==0) v.push_back(act); mapa[act]+=(x.first-last); maks1=max(maks1,mapa[act]); } last=x.first; act=(act-x.second+mod)%mod; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); pre(); int a; long long b,c,d,e,f,g; cin>>a>>b>>c; for(int x=0;x<a;x++) { cin>>d>>e>>f>>g; v1.push_back(make_pair(min(d,f),pot[x])); v1.push_back(make_pair(max(d,f),-pot[x])); v2.push_back(make_pair(min(e,g),pot[x])); v2.push_back(make_pair(max(e,g),-pot[x])); } sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end()); znajdz(b); maks2=maks1; maks1=0; v1=v2; for(auto x:v) mapa[x]=0; znajdz(c); long long maks=maks2; cout<<maks*maks1; return 0; } |