Pagini recente » Cod sursa (job #2556516) | Cod sursa (job #2434665) | Cod sursa (job #644867) | Cod sursa (job #1122874) | Cod sursa (job #2498444)
#include <fstream>
#include <climits>
using namespace std;
ifstream fin("reuniune.in");
ofstream fout("reuniune.out");
long long A,P;
struct dreptunghi
{
long long x,y,x1,y1;
}a[4];
dreptunghi arie(dreptunghi a,dreptunghi b)
{
dreptunghi r={max(a.x,b.x),max(a.y,b.y),min(b.x1,a.x1),min(a.y1,b.y1)};
if(r.x>r.x1 || r.y>r.y1)
r={0,0,0,0};
return r;
}
long long obtARIE(dreptunghi a)
{
return (a.x1-a.x)*(a.y1-a.y);
}
long long obtPERIMETRU(dreptunghi a)
{
return ((a.x1-a.x)+(a.y1-a.y))*2;
}
int main()
{
for(short int i=1 ; i<=3; i++)
{
fin>>a[i].x>>a[i].y;
fin>>a[i].x1>>a[i].y1;
A+=obtARIE(a[i]);
P+=obtPERIMETRU(a[i]);
}
A-=obtARIE(arie(a[1],a[2]))+obtARIE(arie(a[1],a[3]))+obtARIE(arie(a[2],a[3]))-obtARIE(arie(a[1],arie(a[2],a[3])));
P-=obtPERIMETRU(arie(a[1],a[2]))+obtPERIMETRU(arie(a[1],a[3]))+obtPERIMETRU(arie(a[2],a[3]))-obtPERIMETRU(arie(a[1],arie(a[2],a[3])));
fout<<A<<' '<<P;
return 0;
}