Pagini recente » Cod sursa (job #1400726) | Cod sursa (job #2813467) | Cod sursa (job #167555) | Cod sursa (job #1322144) | Cod sursa (job #1225472)
#include <cstdio>
#include <algorithm>
using namespace std;
struct DREPTUNGHI
{
int x0,y0,x1,y1;
};
long long arie(DREPTUNGHI d)
{
return (((long long)d.x1-d.x0)*(d.y1-d.y0));
}
long long perm(DREPTUNGHI d)
{
return (((long long)d.x1-d.x0)+(d.y1-d.y0))<<1;
}
DREPTUNGHI intersectie(DREPTUNGHI d1,DREPTUNGHI d2)
{
DREPTUNGHI temp;
temp.x0=max(d1.x0,d2.x0);
temp.y0=max(d1.y0,d2.y0);
temp.x1=min(d1.x1,d2.x1);
temp.y1=min(d1.y1,d2.y1);
if (temp.x1<temp.x0 || temp.y0>temp.y1)
temp.x0=temp.x1=temp.y1=temp.y0=0;
return temp;
}
int main()
{
freopen("reuniune.in","r",stdin);
freopen("reuniune.out","w",stdout);
DREPTUNGHI d1,d2,d3,i1,i2,i3,i;
scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&d1.x0,&d1.y0,&d1.x1,&d1.y1,&d2.x0,&d2.y0,&d2.x1,&d2.y1,&d3.x0,&d3.y0,&d3.x1,&d3.y1);
i1=intersectie(d1,d2);
i2=intersectie(d2,d3);
i3=intersectie(d3,d1);
i=intersectie(i1,d3);
long long arietotal=arie(d1)+arie(d2)+arie(d3)+arie(i)-arie(i1)-arie(i2)-arie(i3);
long long permtotal=perm(d1)+perm(d2)+perm(d3)+perm(i)-perm(i1)-perm(i2)-perm(i3);
printf("%lld %lld\n",arietotal,permtotal);
return 0;
}