Pagini recente » Cod sursa (job #3349281) | Cod sursa (job #3351880) | Cod sursa (job #2130484) | Cod sursa (job #1135397) | Cod sursa (job #3322338)
#include <iostream>
#include <fstream>
#define ll long long
using namespace std;
ifstream f("reuniune.in");
ofstream g("reuniune.out");
struct dreptunghi
{
ll x,y,A,B;
}d[4];
ll ar(dreptunghi a)
{
return (a.A-a.x)*(a.B-a.y);
}
ll per(dreptunghi a)
{
return 2*(a.A-a.x+a.B-a.y);
}
dreptunghi inters(dreptunghi a, dreptunghi b)
{
dreptunghi c,d;
c.x=max(a.x,b.x);
c.y=max(a.y,b.y);
c.A=min(a.A,b.A);
c.B=min(a.B,b.B);
if(c.x<=c.A&&c.y<=c.B)
return c;
d.x=d.y=d.A=d.B=0;
return d;
}
int main()
{
for(int i=1;i<=3;i++)
f>>d[i].x>>d[i].y>>d[i].A>>d[i].B;
g<<ar(d[1])+ar(d[2])+ar(d[3])-ar(inters(d[1],d[2]))-ar(inters(d[2],d[3]))-ar(inters(d[1],d[3]))+ar(inters(inters(d[1],d[2]),d[3]))<<" ";
g<<per(d[1])+per(d[2])+per(d[3])-per(inters(d[1],d[2]))-per(inters(d[2],d[3]))-per(inters(d[1],d[3]))+per(inters(inters(d[1],d[2]),d[3]));
return 0;
}