#include <bits/stdc++.h>
#define booost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define bp __builtin_popcount
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < PII, int > PIII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
const LL MOD=1e9+7;
const LL LLINF=1e18+7;
const int C=500009;
vector<PII> evX,evY;
bitset<C> bx,by;
unordered_map<bitset<C>,LL> MPX,MPY;
int main()
{
//booost;
//freopen("C:/Users/kucha/Documents/ISIM 5. semestr/PA/tertests/B1100.in","r",stdin);
int X,Y,n,x1,x2,y1,y2;
scanf("%d %d %d",&n,&X,&Y);
//cin>>n>>X>>Y;
for(int i=0;i<n;i++)
{
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
//cin>>x1>>y1>>x2>>y2;
if(x1>x2)
{
swap(x1,x2);
}
if(y1>y2)
{
swap(y1,y2);
}
evX.push_back({x1,i+1});
evY.push_back({y1,i+1});
evX.push_back({x2,i+1});
evY.push_back({y2,i+1});
}
evX.push_back({0,0});
evX.push_back({X,0});
evY.push_back({0,0});
evY.push_back({Y,0});
sort(evX.begin(),evX.end());
sort(evY.begin(),evY.end());
LL xmax=0,ymax=0;
for(int i=0;i+1<evX.size();i++)
{
PII cur=evX[i],next=evX[i+1];
bx.flip(cur.se);
MPX[bx]+=next.fi-cur.fi;
xmax=max(xmax,MPX[bx]);
cur=evY[i],next=evY[i+1];
by.flip(cur.se);
MPY[by]+=next.fi-cur.fi;
ymax=max(ymax,MPY[by]);
}
printf("%lld\n",xmax*ymax);
}
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 | #include <bits/stdc++.h> #define booost ios_base::sync_with_stdio(false); cin.tie(nullptr); #define fi first #define se second #define bp __builtin_popcount using namespace std; typedef long long LL; typedef long double LD; typedef pair < int, int > PII; typedef pair < PII, int > PIII; typedef pair < LL, LL > PLL; typedef pair < LD, LD > PDD; const LL MOD=1e9+7; const LL LLINF=1e18+7; const int C=500009; vector<PII> evX,evY; bitset<C> bx,by; unordered_map<bitset<C>,LL> MPX,MPY; int main() { //booost; //freopen("C:/Users/kucha/Documents/ISIM 5. semestr/PA/tertests/B1100.in","r",stdin); int X,Y,n,x1,x2,y1,y2; scanf("%d %d %d",&n,&X,&Y); //cin>>n>>X>>Y; for(int i=0;i<n;i++) { scanf("%d %d %d %d",&x1,&y1,&x2,&y2); //cin>>x1>>y1>>x2>>y2; if(x1>x2) { swap(x1,x2); } if(y1>y2) { swap(y1,y2); } evX.push_back({x1,i+1}); evY.push_back({y1,i+1}); evX.push_back({x2,i+1}); evY.push_back({y2,i+1}); } evX.push_back({0,0}); evX.push_back({X,0}); evY.push_back({0,0}); evY.push_back({Y,0}); sort(evX.begin(),evX.end()); sort(evY.begin(),evY.end()); LL xmax=0,ymax=0; for(int i=0;i+1<evX.size();i++) { PII cur=evX[i],next=evX[i+1]; bx.flip(cur.se); MPX[bx]+=next.fi-cur.fi; xmax=max(xmax,MPX[bx]); cur=evY[i],next=evY[i+1]; by.flip(cur.se); MPY[by]+=next.fi-cur.fi; ymax=max(ymax,MPY[by]); } printf("%lld\n",xmax*ymax); } |
English