Pagini recente » Monitorul de evaluare | Cod sursa (job #1786944) | Cod sursa (job #828872) | Cod sursa (job #1693663) | Cod sursa (job #1982880)
#include <fstream>
using namespace std;
ifstream in("reuniune.in");
ofstream out("reuniune.out");
struct Points{
long long x0;
long long y0;
long long x1;
long long y1;
};
Points a, b, c;
long long arie, peri;
long long computear(Points h){
return 1LL * (h.x1 - h.x0) * (h.y1 - h.y0);
}
long long computeperi(Points h){
return 1LL * ((h.x1 - h.x0) + (h.y1 - h.y0)) * 2;
}
Points intersection(Points a, Points b){
Points aux;
aux.x0 = max(a.x0, b.x0);
aux.x1 = min(a.x1, b.x1);
aux.y0 = max(a.y0, b.y0);
aux.y1 = min(a.y1, b.y1);
if(aux.x1 < aux.x0 || aux.y1 < aux.y0){
aux.x0 = 0;
aux.x1 = 0;
aux.y0 = 0;
aux.y1 = 0;
}
return aux;
}
int main()
{
in >> a.x0 >> a.y0 >> a.x1 >> a.y1;
in >> b.x0 >> b.y0 >> b.x1 >> b.y1;
in >> c.x0 >> c.y0 >> c.x1 >> c.y1;
in.close();
arie = computear(a) + computear(b) + computear(c);
arie -= computear(intersection(a, b));
arie -= computear(intersection(b, c));
arie -= computear(intersection(a, c));
arie += computear(intersection(c, intersection(a, b)));
peri = computeperi(a) + computeperi(b) + computeperi(c);
peri -= computeperi(intersection(a, b));
peri -= computeperi(intersection(b, c));
peri -= computeperi(intersection(a, c));
peri += computeperi(intersection(c, intersection(a, b)));
out << arie << ' ' << peri << '\n';
out.close();
return 0;
}