Pagini recente » Cod sursa (job #699605) | Cod sursa (job #2941400) | Cod sursa (job #2908467) | Cod sursa (job #3159517) | Cod sursa (job #2653826)
#include<fstream>
// #define ll long long
using namespace std;
ifstream f("reuniune.in"); ofstream g("reuniune.out");
typedef long long ll;
struct drept {int x0,y0,x1,y1;} d[4];
ll car(drept p)
{ return 1LL*(p.x1-p.x0)*(p.y1-p.y0);}
ll cper(drept p)
{ return 2LL*(p.x1-p.x0+p.y1-p.y0);}
drept iter(drept a, drept b)
{ drept c;
if(a.x0<b.x0) c.x0=b.x0; else c.x0=a.x0;
if(a.y0<b.y0) c.y0=b.y0; else c.y0=a.y0;
if(a.x1>b.x1) c.x1=b.x1; else c.x1=a.x1;
if(a.y1>b.y1) c.y1=b.y1; else c.y1=a.y1;
if(c.x0>c.x1 || c.y0>c.y1) return d[0];
return c;
}
int main()
{ for(int i=1;i<=3;i++) f>>d[i].x0>>d[i].y0>>d[i].x1>>d[i].y1;
ll arie,perimetru;
arie=car(d[1])+car(d[2])+car(d[3])-car(iter(d[1],d[2]))-car(iter(d[1],d[3]))-car(iter(d[3],d[2]))
+car(iter(iter(d[1],d[2]),d[3]));
perimetru=cper(d[1])+cper(d[2])+cper(d[3])-cper(iter(d[1],d[2]))-cper(iter(d[1],d[3]))-cper(iter(d[3],d[2]))
+cper(iter(iter(d[1],d[2]),d[3]));
g<<arie<<' '<<perimetru;
g.close();
return 0;
}