Pagini recente » Rating Eduard Zburator (mufasa) | Cod sursa (job #2013426) | de_ce_sa_ne_certam_iubi | Cod sursa (job #569881) | Cod sursa (job #489949)
Cod sursa(job #489949)
/**aria se calc la fel ca si perimetru
*Calc cu pinex
*/
#include <cstdio>
#include <iostream>
#define LL long long
using namespace std;
LL n;
struct dreptunghi {
LL x1,y1,x2,y2;
} d1,d2,d3;
dreptunghi reuniune(dreptunghi a, dreptunghi b) {//returneaza dreptunghiul reuniune a celor 2
dreptunghi sol;
sol.x1=max(a.x1,b.x1);
sol.y1=max(a.y1,b.y1);
sol.x2=min(a.x2,b.x2);
sol.y2=min(a.y2,b.y2);
if (sol.x1>sol.x2 || sol.y1>sol.y2) //reuniune vida
sol.x1=sol.x2=sol.y1=sol.y2=0;
return sol;
}
LL arie(dreptunghi a) {
return (a.x2-a.x1)*(a.y2-a.y1);
}
LL perimetru(dreptunghi a) {
return 2*(a.x2-a.x1+a.y2-a.y1);
}
int main()
{
freopen("reuniune.in","r",stdin);
freopen("reuniune.out","w",stdout);
scanf("%lld%lld%lld%lld %lld%lld%lld%lld %lld%lld%lld%lld",d1.x1,d1.y1,d1.x2,d1.y2, d2.x1,d2.y1,d2.x2,d2.y2, d3.x1,d3.y1,d3.x2,d3.y2);
LL sarie=arie(d1)+arie(d2)+arie(d3) -
arie(reuniune(d1,d2)) - arie(reuniune(d2,d3)) - arie(reuniune(d1,d3)) +
arie(reuniune(reuniune(d1,d2),d3));
LL sperimetru=perimetru(d1)+perimetru(d2)+perimetru(d3) -
perimetru(reuniune(d1,d2)) - perimetru(reuniune(d2,d3)) - perimetru(reuniune(d1,d3)) +
perimetru(reuniune(reuniune(d1,d2),d3));
printf("%d %d",sarie, sperimetru);
return 0;
}