Pagini recente » Cod sursa (job #1860806) | Cod sursa (job #2887622) | Cod sursa (job #2960126) | Cod sursa (job #508521) | Cod sursa (job #782099)
Cod sursa(job #782099)
#include <fstream>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
ifstream f("reuniune.in");
ofstream g("reuniune.out");
struct Drept
{
LL x1,y1,x2,y2;
};
Drept A,B,C;
Drept AxB,AxC,BxC,AxBxC;
LL S,P;
LL M[20][20];
LL X[20],Y[20],x,y;
Drept Reunite (const Drept& A, const Drept& B)
{
Drept R;
R.x1=max(A.x1,B.x1);
R.x2=min(A.x2,B.x2);
R.y1=max(A.y1,B.y1);
R.y2=min(A.y2,B.y2);
if (R.x1<A.x1 || R.x1<B.x1 || R.x1>A.x2 || R.x2>B.x2 || R.y1<A.y1 || R.y1<B.y1 || R.y1>A.y2 || R.y2>B.y2)
{
R.x1=R.x2=R.y1=R.y2=2000000000;
}
return R;
}
LL Area (const Drept &A)
{
return max(0LL,(A.x2-A.x1)*(A.y2-A.y1));
}
LL Perimeter (const Drept &A)
{
return max(0LL,2*(A.x2-A.x1+A.y2-A.y1));
}
int main ()
{
f >> A.x1 >> A.y1 >> A.x2 >> A.y2;
f >> B.x1 >> B.y1 >> B.x2 >> B.y2;
f >> C.x1 >> C.y1 >> C.x2 >> C.y2;
AxB=Reunite(A,B);
AxC=Reunite(A,C);
BxC=Reunite(B,C);
AxBxC=Reunite(AxB,C);
S=Area(A)+Area(B)+Area(C)-Area(AxB)-Area(AxC)-Area(BxC)+Area(AxBxC);
P=Perimeter(A)+Perimeter(B)+Perimeter(C)-Perimeter(AxB)-Perimeter(AxC)-Perimeter(BxC)+Perimeter(AxBxC);
g << S << ' ' << P << '\n';
f.close();
g.close();
return 0;
}