Pagini recente » Cod sursa (job #1315743) | Cod sursa (job #132790) | Cod sursa (job #1728850) | Cod sursa (job #2524066) | Cod sursa (job #2703921)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("reuniune.in");
ofstream fout("reuniune.out");
struct dreptunghi
{
long long x0, y0, x1, y1;
} d[4];
long long arie(dreptunghi n)
{
return (n.y1 - n.y0) * (n.x1 - n.x0);
}
long long perimetru(dreptunghi n)
{
return 2 * ((n.y1 - n. y0) + (n.x1 - n.x0));
}
dreptunghi intersectie(dreptunghi a, dreptunghi b)
{
dreptunghi c;
c.x0 = max(a.x0, b.x0);
c.y0 = max(a.y0, b.y0);
c.x1 = min(a.x1, b.x1);
c.y1 = min(a.y1, b.y1);
return c;
}
int main()
{
fin >> d[1].x0 >> d[1].y0 >> d[1].x1 >> d[1].y1;
fin >> d[2].x0 >> d[2].y0 >> d[2].x1 >> d[2].y1;
fin >> d[3].x0 >> d[3].y0 >> d[3].x1 >> d[3].y1;
fout << arie(d[1]) + arie(d[2]) + arie(d[3]) - arie(intersectie(d[1], d[2])) - arie(intersectie(d[2], d[3])) - arie(intersectie(d[3], d[1])) + arie(intersectie(intersectie(d[1], d[2]), d[3]));
fout << " ";
fout << perimetru(d[1]) + perimetru(d[2]) + perimetru(d[3]) - perimetru(intersectie(d[1], d[2])) - perimetru(intersectie(d[2], d[3])) - perimetru(intersectie(d[3], d[1])) + perimetru(intersectie(intersectie(d[1], d[2]), d[3]));
return 0;
}