Pagini recente » Cod sursa (job #673183) | Cod sursa (job #2124020) | Cod sursa (job #1433594) | Cod sursa (job #568712) | Cod sursa (job #2086079)
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("reuniune.in");
ofstream fout("reuniune.out");
unsigned long long arr,pmr;
struct chestie
{
int x1,y1,x2,y2;
} A,B,C,AB,BC,AC,T;
unsigned long long pm(chestie X);
unsigned long long ar(chestie X);
chestie clean(chestie X);
bool wrong(chestie X);
void daca();
chestie intersect(chestie X, chestie Y);
int main()
{
fin>>A.x1>>A.y1>>A.x2>>A.y2;
fin>>B.x1>>B.y1>>B.x2>>B.y2;
fin>>C.x1>>C.y1>>C.x2>>C.y2;
AB=intersect(A,B);
BC=intersect(B,C);
AC=intersect(A,C);
T=intersect(AB,C);
daca();
pmr=pm(A)+pm(B)+pm(C)-pm(AB)-pm(BC)-pm(AC)+pm(T);
arr=ar(A)+ar(B)+ar(C)-ar(AB)-ar(BC)-ar(AC)+ar(T);
fout<<arr<<' '<<pmr<<'\n';
return 0;
}
bool wrong(chestie X)
{
if(X.x1>X.x2)
return 1;
if(X.y1>X.y2)
return 1;
return 0;
}
chestie clean(chestie X)
{
X.x1=X.x2=X.y1=X.y2=0;
return X;
}
void daca()
{
if(wrong(AB)){
AB=clean(AB);
T=clean(T);
}
if(wrong(AC)){
AC=clean(AC);
T=clean(T);
}
if(wrong(BC)){
BC=clean(BC);
T=clean(T);
}
if(wrong(T)){
T=clean(T);
}
}
unsigned long long ar(chestie X)
{
int lg=abs(X.x2-X.x1);
int lt=abs(X.y2-X.y1);
unsigned long long aria=lt*lg;
return aria;
}
unsigned long long pm(chestie X)
{
int lg=abs(X.x2-X.x1);
int lt=abs(X.y2-X.y1);
int P=lt*2+lg*2;
return P;
}
chestie intersect(chestie X, chestie Y)
{
chestie XY;
XY.x1=XY.x2=XY.y1=XY.y2=0;
XY.x1=max(X.x1,Y.x1);
XY.x2=min(X.x2,Y.x2);
XY.y1=max(X.y1,Y.y1);
XY.y2=min(X.y2,Y.y2);
return XY;
}