Pagini recente » Cod sursa (job #1834038) | Cod sursa (job #144143) | Cod sursa (job #158695) | Cod sursa (job #1463803) | Cod sursa (job #1497470)
#include <fstream>
using namespace std;
ifstream fin("reuniune.in");
ofstream fout("reuniune.out");
struct dreptunghi{
long long x1,y1,x2,y2;
}A, B, C, AB, AC, BC, D;
long long arie(dreptunghi P)
{
return ((P.x2 - P.x1) * (P.y2 - P.y1));
}
long long perimetru(dreptunghi P)
{
return 2 * ((P.x2 - P.x1) + (P.y2 - P.y1));
}
void intersectie(dreptunghi D1, dreptunghi D2, dreptunghi &D3)
{
D3.x1 = max(D1.x1, D2.x1);
D3.y1 = max(D1.y1, D2.y1);
D3.x2 = min(D1.x2, D2.x2);
D3.y2 = min(D1.y2, D2.y2);
if( D3.x1 > D3.x2 || D3.y1 > D3.y2)
{
D3.x1 = 0;
D3.x2 = 0;
D3.y1 = 0;
D3.y2 = 0;
}
}
int main()
{
fin >> A.x1 >> A.y1 >> A.x2 >> A.y2;
fin >> B.x1 >> B.y1 >> B.x2 >> B.y2;
fin >> C.x1 >> C.y1 >> C.x2 >> C.y2;
intersectie(A, B, AB);
intersectie(A, C, AC);
intersectie(B, C, BC);
intersectie(AB, C, D);
fout << arie (A) + arie(B) + arie(C) - arie(AB) - arie(AC) - arie(BC) + arie(D) << " ";
fout << perimetru(A) + perimetru(B) + perimetru(C) - perimetru(AB) - perimetru(AC) - perimetru(BC) + perimetru(D);
return 0;
}