Pagini recente » Cod sursa (job #2660289) | Cod sursa (job #2125634) | Cod sursa (job #1331960) | Cod sursa (job #3209172) | Cod sursa (job #2086086)
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("reuniune.in");
ofstream fout("reuniune.out");
long long arr,pmr;
struct chestie{
int x1,y1,x2,y2;
} A,B,C,AB,BC,AC,T;
long long pm(chestie X);
long long ar(chestie X);
chestie clean(chestie X);
bool wrong(chestie X);
void check();
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(A,BC);
///
check();
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 check()
{
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);
}
}
long long ar(chestie X)
{
long long lg=1LL*(X.x2-X.x1);
long long lt=1LL*(X.y2-X.y1);
long long aria=lt*lg;
return aria;
}
long long pm(chestie X)
{
long long lg=1LL*(X.x2-X.x1);
long long lt=1LL*(X.y2-X.y1);
long long P=1LL*(lt+lg)*2;
return P;
}
chestie intersect(chestie X, chestie Y)
{
chestie XY;
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;
}