Pagini recente » Rating Sobaru Calin-George (calin2014calculatoristul) | Cod sursa (job #2275928) | Cod sursa (job #603776) | Rating bossu tau (vasile101) | Cod sursa (job #1845045)
#include <cstdio>
using namespace std;
FILE *f, *g;
typedef long long ll;
typedef unsigned long long llu;
inline ll mxa(ll a, ll b)
{
return (a > b ? a : b);
}
inline ll mna(ll a, ll b)
{
return (a < b ? a : b);
}
struct drept
{
ll x1, y1, x2, y2;
///Intersectia a doua dreptunghiuri
drept operator+(const drept &x)
{
drept r;
r.x1 = mxa(x1, x.x1);
r.x2 = mna(x2, x.x2);
r.y1 = mxa(y1, x.y1);
r.y2 = mna(y2, x.y2);
if(r.x1 > r.x2 || r.y1 > r.y2)
r.x1 = r.x2 = r.y1 = r.y2 = 0;
return r;
}
};
///Aria unui dreptunghi
inline llu getArie(drept x)
{
return ((x.x2 - x.x1) * (x.y2 - x.y1));
}
///Perimetrul unui dreptunghi
inline llu getPrmt(drept x)
{
return (2LL * ((x.x2 - x.x1) + (x.y2 - x.y1)));
}
drept a, b, c;
unsigned long long aria, prmt;
void readFile()
{
f = fopen("reuniune.in", "r");
fscanf(f, "%lld%lld%lld%lld", &a.x1, &a.y1, &a.x2, &a.y2);
fscanf(f, "%lld%lld%lld%lld", &b.x1, &b.y1, &b.x2, &b.y2);
fscanf(f, "%lld%lld%lld%lld", &c.x1, &c.y1, &c.x2, &c.y2);
fclose(f);
}
void solve()
{
///Calculam aria si perimetrul folosind principiul includerii si excluderii ( http://www.infoarena.ro/problema/pinex )
aria = getArie(a) + getArie(b) + getArie(c) - getArie(a + b) - getArie(a + c) - getArie(b + c) + getArie(a + b + c);
prmt = getPrmt(a) + getPrmt(b) + getPrmt(c) - getPrmt(a + b) - getPrmt(a + c) - getPrmt(b + c) + getPrmt(a + b + c);
}
void printFile()
{
g = fopen("reuniune.out", "w");
fprintf(g, "%llu %llu\n", aria, prmt);
fclose(g);
}
int main()
{
readFile();
solve();
printFile();
return 0;
}