Cod sursa(job #998277)

Utilizator chiriacandrei25Chiriac Andrei chiriacandrei25 Data 16 septembrie 2013 17:42:27
Problema Reuniune Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.1 kb
#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;
}