# Cod sursa(job #43421)

Utilizator Data 30 martie 2007 07:37:31 Reuniune 20 cpp done Arhiva de probleme 1.58 kb
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

long aria (int x1, int y1, int x2, int y2)
{
return abs((x2-x1)*(y2-y1));

}

long perimetru(int x1, int y1, int x2, int y2)
{
return abs((x2-x1)*2) +abs((y2-y1)*2);
}

long min (int a, int b)
{
if (a<=b) return a;
else return b;
}

long max (int a, int b)
{
if (a<=b) return b;
else return a;
}

int main()
{
freopen("reuniune.in","r", stdin);
freopen("reuniune.out","w", stdout);

long x1s,x1d,y1s,y1d,x2s,x2d,y2s,y2d,x3s,x3d,y3s,y3d;
long arie=0, perim=0;

scanf("%ld %ld %ld %ld", &x1s, &y1s, &x1d, &y1d);
scanf("%ld %ld %ld %ld", &x2s, &y2s, &x2d, &y2d);
scanf("%ld %ld %ld %ld", &x3s, &y3s, &x3d, &y3d);
long ts,vs,tts,vvs;

arie+=aria(x1s,y1s,x1d,y1d);
arie+=aria(x2s,y2s,x2d,y2d);
arie+=aria(x3s,y3s,x3d,y3d);

perim+=perimetru(x1s,y1s,x1d,y1d);
perim+=perimetru(x2s,y2s,x2d,y2d);
perim+=perimetru(x3s,y3s,x3d,y3d);

ts = max(x1s,x2s);
vs = max(y1s,y2s);
tts = min (x1d,x2d);
vvs = min (y1d,y2d);
arie-=aria(ts,vs,tts,vvs);
perim-=perimetru(ts,vs,tts,vvs);

ts = max(x1s,x3s);
vs = max(y1s,y3s);
tts = min (x1d,x3d);
vvs = min (y1d,y3d);
arie-=aria(ts,vs,tts,vvs);
perim-=perimetru(ts,vs,tts,vvs);

ts = max(x3s,x2s);
vs = max(y3s,y2s);
tts = min (x3d,x2d);
vvs = min (y3d,y2d);
arie-=aria(ts,vs,tts,vvs);
perim-=perimetru(ts,vs,tts,vvs);

long xts,xvs,xtts,xvvs;

xts = max(x1s,ts);
xvs = max(y1s,vs);
xtts = min (x1d,tts);
xvvs = min (y1d,vvs);
arie+=aria(xts,xvs,xtts,xvvs);
perim+=perimetru(xts,xvs,xtts,xvvs);

printf("%ld %ld", arie,perim);
return 0;
}