Cod sursa(job #998204)

Utilizator scipianusFMI Ciprian Olariu scipianus Data 16 septembrie 2013 13:09:16
Problema Reuniune Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#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;
}