Pagini recente » Cod sursa (job #381888) | Diferente pentru implica-te/arhiva-educationala intre reviziile 223 si 195 | Cod sursa (job #3282718) | Cod sursa (job #3277984) | Cod sursa (job #3254856)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream f("reuniune.in");
ofstream g("reuniune.out");
struct cel
{
long long x1, y1, x2, y2;
}a, b, c;
long long P( cel 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 A( cel a )
{
if ( a.x1 > a.x2 || a.y1 > a.y2 )
return 0;
return abs( a.x1 - a.x2 ) * abs( a.y1 - a.y2 );
}
cel intersectie( cel a, cel b )
{
return { max( a.x1, b.x1 ), max( a.y1, b.y1 ), min( a.x2, b.x2 ), min( a.y2, b.y2 ) };
}
int main()
{
f >> a.x1 >> a.y1 >> a.x2 >> a.y2 >> b.x1 >> b.y1 >> b.x2 >> b.y2 >> c.x1 >> c.y1 >> c.x2 >> c.y2;
g << A(a) + A(b) + A(c) - A(intersectie( a, b )) - A(intersectie( b, c )) - A(intersectie( a, c )) + A(intersectie( a, intersectie( b, c ) )) << " ";
g << P(a) + P(b) + P(c) - P(intersectie( a, b )) - P(intersectie( b, c )) - P(intersectie( a, c )) + P(intersectie( a, intersectie( b, c ) ));
return 0;
}