# Cod sursa(job #2750852)

Utilizator Data 13 mai 2021 14:02:23 Reuniune 20 cpp-64 done Arhiva de probleme 1.29 kb
``````//#include <iostream>
#include <fstream>
using namespace std;
ifstream cin("reuniune.in");
ofstream cout("reuniune.out");
struct dreptunghi{
int x0,y0,x1,y1,arie;
}v[10];
dreptunghi intersectie(dreptunghi a,dreptunghi b){
dreptunghi x;
if(a.arie==0 or b.arie==0){
x.arie=0;
return x;
}
x.x0=max(a.x0,b.x0);
x.y0=max(a.y0,b.y0);
x.x1=min(a.x1,b.x1);
x.y1=min(a.y1,b.y1);
if(x.x0>=x.x1 or x.y0>=x.y1){
x.arie=0;
}
else
x.arie=(x.x1-x.x0)*(x.y1-x.y0);
return x;
}
int main()
{
int mi1=1000000005,mi2=1000000005,ma1=-1000000005,ma2=-1000000005;
for(int i=1;i<=3;i++){
cin>>v[i].x0>>v[i].y0>>v[i].x1>>v[i].y1;
if(v[i].x0>=v[i].x1 or v[i].y0>=v[i].y1){
v[i].arie=0;
}
else
v[i].arie=(v[i].x1-v[i].x0)*(v[i].y1-v[i].y0);
mi1=min(mi1,v[i].x0);
mi2=min(mi2,v[i].y0);
ma1=max(ma1,v[i].x1);
ma2=max(ma2,v[i].y1);
}
v[4]=intersectie(v[1],v[2]);
v[5]=intersectie(v[1],v[3]);
v[6]=intersectie(v[3],v[2]);
v[7]=intersectie(v[4],intersectie(v[5],v[6]));
cout<<v[1].arie+v[2].arie+v[3].arie-v[4].arie-v[5].arie-v[6].arie+v[7].arie<<" ";
cout<<-2*((mi1-ma1)+(mi2-ma2));
return 0;
}
``````