Pagini recente » Cod sursa (job #2785435) | Cod sursa (job #655911) | Cod sursa (job #2484457) | Cod sursa (job #2907407) | Cod sursa (job #998277)
Cod sursa(job #998277)
#include <fstream>
using namespace std;
struct Dreptunghi
{
long long xst,yst,xdr,ydr;
};
Dreptunghi A,B,C;
inline void Read()
{
ifstream fin("reuniune.in");
fin>>A.xst>>A.yst>>A.xdr>>A.ydr;
fin>>B.xst>>B.yst>>B.xdr>>B.ydr;
fin>>C.xst>>C.yst>>C.xdr>>C.ydr;
fin.close();
}
inline long long S(Dreptunghi A)
{
return ((A.xdr-A.xst)*(A.ydr-A.yst));
}
inline long long P(Dreptunghi A)
{
return 2LL*((A.xdr-A.xst)+(A.ydr-A.yst));
}
inline Dreptunghi Int(Dreptunghi A, Dreptunghi B)
{
Dreptunghi sol;
sol.xst=max(A.xst,B.xst);
sol.xdr=min(A.xdr,B.xdr);
sol.yst=max(A.yst,B.yst);
sol.ydr=min(A.ydr,B.ydr);
if(sol.xst>sol.xdr || sol.xst>sol.ydr)
sol.xst=sol.xdr=sol.yst=sol.ydr=0;
return sol;
}
int main()
{
long long sol1,sol2;
Read();
ofstream fout("reuniune.out");
sol1=S(A)+S(B)+S(C)-S(Int(A,B))-S(Int(A,C))-S(Int(B,C))+S(Int(Int(A,B),C));
sol2=P(A)+P(B)+P(C)-P(Int(A,B))-P(Int(A,C))-P(Int(B,C))+P(Int(Int(A,B),C));
fout<<sol1<<" "<<sol2<<"\n";
fout.close();
return 0;
}