Pagini recente » Cod sursa (job #2657941) | Cod sursa (job #2106845) | Cod sursa (job #1202263) | Cod sursa (job #40) | Cod sursa (job #3184016)
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
ifstream cin("reuniune.in");
ofstream cout("reuniune.out");
struct shape
{
long long int x1,y1,x2,y2;
};
long long int P(shape a)
{
if(a.x1>a.x2 || a.y1>a.y2) return 0;
return 2*(abs(a.x1-a.x2)+abs(a.y1-a.y2));
}
long long int A(shape a)
{
if(a.x1>a.x2 || a.y1>a.y2) return 0;
return abs(a.x1-a.x2)*abs(a.y1-a.y2);
}
shape Intersection(shape a,shape b)
{
return {max(a.x1,b.x1),max(a.y1,b.y1),min(a.x2,b.x2),min(a.y2,b.y2)};
}
int main()
{
shape a,b,c;
cin>>a.x1>>a.y1>>a.x2>>a.y2>>b.x1>>b.y1>>b.x2>>b.y2>>c.x1>>c.y1>>c.x2>>c.y2;
cout<<A(a)+A(b)+A(c)-A(Intersection(a,b))-A(Intersection(b,c))-A(Intersection(a,c))+A(Intersection(a,Intersection(b,c)))<<" ";
cout<<P(a)+P(b)+P(c)-P(Intersection(a,b))-P(Intersection(b,c))-P(Intersection(a,c))+P(Intersection(a,Intersection(b,c)));
return 0;
}