Pagini recente » Cod sursa (job #2574634) | Cod sursa (job #984686) | Cod sursa (job #845598) | Cod sursa (job #450978) | Cod sursa (job #2407228)
#include <fstream>
#define pii pair <int, int>
#define Poly pair <pii, pii>
#define x first
#define y second
using namespace std;
ifstream cin ("reuniune.in");
ofstream cout ("reuniune.out");
long long sol;
Poly v[5], a[5];
long long area(Poly a) {
return 1LL * (a.y.x - a.x.x) * (a.y.y - a.x.y);
}
long long peri(Poly a) {
return 2LL * (a.y.y - a.x.y + a.y.x - a.x.x);
}
Poly poly(Poly a, Poly b) {
Poly c;
c = {{max(a.x.x, b.x.x), max(a.x.y, b.x.y)}, {min(a.y.x, b.y.x), min(a.y.y, b.y.y)}};
if(c.x.x <= c.y.x && c.x.y <= c.y.y)
return c;
return {{0, 0}, {0, 0}};
}
int main() {
for(int i = 1; i <= 3; i++)
cin >> v[i].x.x >> v[i].x.y >> v[i].y.x >> v[i].y.y;
cout << area(v[1]) + area(v[2]) + area(v[3]) - area(poly(v[1], v[2])) - area(poly(v[1], v[3])) - area(poly(v[2], v[3])) + area(poly(v[1], poly(v[2], v[3]))) << " ";
cout << peri(v[1]) + peri(v[2]) + peri(v[3]) - peri(poly(v[1], v[2])) - peri(poly(v[1], v[3])) - peri(poly(v[2], v[3])) + peri(poly(v[1], poly(v[2], v[3])));
return 0;
}