Pagini recente » Cod sursa (job #519111) | Cod sursa (job #1032861) | Borderou de evaluare (job #2019978) | Cod sursa (job #234346) | Cod sursa (job #998204)
Cod sursa(job #998204)
#include<fstream>
#include<cmath>
using namespace std;
struct Dreptunghi{long long xa,ya,xb,yb;};
Dreptunghi A,B,C;
inline Dreptunghi Int(Dreptunghi X,Dreptunghi Y)
{
Dreptunghi rez;
rez.xa=max(X.xa,Y.xa);
rez.ya=max(X.ya,Y.ya);
rez.xb=min(X.xb,Y.xb);
rez.yb=min(X.yb,Y.yb);
if(rez.xa>rez.xb || rez.ya>rez.yb)
rez.xa=rez.ya=rez.xb=rez.yb=0;
return rez;
}
inline long long S(Dreptunghi X)
{
return (X.xb-X.xa)*(X.yb-X.ya);
}
inline long long P(Dreptunghi X)
{
return 2LL*(X.xb-X.xa+X.yb-X.ya);
}
int main()
{
ifstream fin("reuniune.in");
fin>>A.xa>>A.ya>>A.xb>>A.yb;
fin>>B.xa>>B.ya>>B.xb>>B.yb;
fin>>C.xa>>C.ya>>C.xb>>C.yb;
fin.close();
ofstream fout("reuniune.out");
fout<<(S(A)+S(B)+S(C)-S(Int(A,B))-S(Int(B,C))-S(Int(A,C))+S(Int(Int(A,B),C)))<<' ';
fout<<(P(A)+P(B)+P(C)-P(Int(A,B))-P(Int(B,C))-P(Int(A,C))+P(Int(Int(A,B),C)))<<"\n";
fout.close();
return 0;
}