Pagini recente » Cod sursa (job #1754829) | Cod sursa (job #460038) | Cod sursa (job #193685) | Cod sursa (job #1102227) | Cod sursa (job #965529)
Cod sursa(job #965529)
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
struct drunghi{
LL x0,y0;
int x1,y1;
}v[3];
LL area(const drunghi & P)
{
const LL dx = P.x1 - P.x0;
const LL dy = P.y1 - P.y0;
return dx * dy;
}
LL perim(const drunghi &P)
{
const LL dx = P.x1 - P.x0;
const LL dy = P.y1 - P.y0;
return 2*(dx + dy);
}
drunghi LLersect(const drunghi &a,const drunghi &b)
{
drunghi ret;
ret.x0 = max(a.x0,b.x0);
ret.x1 = min(a.x1,b.x1);
ret.y0 = max(a.y0,b.y0);
ret.y1 = min(a.y1,b.y1);
if(ret.x1 < ret.x0 || ret.y1 < ret.y0)
return {0,0,0,0};
else return ret;
}
int main()
{
freopen("reuniune.in", "r", stdin);
freopen("reuniune.out", "w", stdout);
LL i;
LL show_area = 0;
LL show_perim = 0;
for(i = 0 ; i < 3 ; ++ i){
scanf("%lld%lld%lld%lld",&v[i].x0,&v[i].y0,&v[i].x1,&v[i].y1);
show_area += area(v[i]);
show_perim += perim(v[i]);
}
drunghi x;
x = LLersect(v[0],v[1]);
show_area -= area(x);
show_perim -= perim(x);
x = LLersect(v[1],v[2]);
show_area -= area(x);
show_perim -= perim(x);
x = LLersect(v[0],v[2]);
show_area -= area(x);
show_perim -= perim(x);
x = LLersect(x,v[1]);
show_area += area(x);
show_perim += perim(x);
printf("%lld %lld\n",show_area,show_perim);
return 0;
}