Cod sursa(job #710220)

Utilizator lehman97Dimulescu David lehman97 Data 9 martie 2012 11:37:08
Problema Reuniune Scor 20
Compilator fpc Status done
Runda Arhiva de probleme Marime 2.44 kb
type vec=record
x1,y1,x2,y2,p,a:longint;
end;
var  v:array[1..3]of vec;
     i,p1,l1,l2,att,pt,a1,a2,b1,b2:longint;



function calculeaza1(x1,x2,y1,y2:longint):longint;
var p,a:longint;
begin
l1:=abs(x2-x1);
l2:=abs(y2-y1);
p:=2*(l1+l2);
calculeaza1:=p;
end;

function calculeaza2(x1,x2,y1,y2:longint):longint;
var p,a:longint;
begin
l1:=abs(x2-x1);
l2:=abs(y2-y1);
a:=l1*l2;
calculeaza2:=a;
end;






procedure intersectie4;
var  xm1,ym1,xm2,ym2,ar,pe:longint;
begin
xm1:=v[3].x1;
if a1>v[3].x1 then
xm1:=a1;
xm2:=v[3].x2;
if a2<v[3].x2 then
xm2:=a2;

ym1:=v[3].y1;
if b1>v[3].y1 then
ym1:=b1;
ym2:=v[3].y2;
if b2<v[3].y2 then
ym2:=b2;
ar:=calculeaza2(xm1,xm2,ym1,ym2);
pe:=calculeaza1(xm1,xm2,ym1,ym2);
inc(att,ar);
inc(pt,pe);
end;



















procedure intersectie3;
var  xm1,ym1,xm2,ym2,ar,pe:longint;
begin
xm1:=v[3].x1;
if v[2].x1>v[3].x1 then
xm1:=v[2].x1;
xm2:=v[3].x2;
if v[2].x2<v[3].x2 then
xm2:=v[2].x2;

ym1:=v[3].y1;
if v[2].y1>v[3].y1 then
ym1:=v[2].y1;
ym2:=v[3].y2;
if v[2].y2<v[3].y2 then
ym2:=v[2].y2;
ar:=calculeaza2(xm1,xm2,ym1,ym2);
pe:=calculeaza1(xm1,xm2,ym1,ym2);
dec(att,ar);
dec(pt,pe);
end;




procedure intersectie2;
var  xm1,ym1,xm2,ym2,ar,pe:longint;
begin
xm1:=v[1].x1;
if v[3].x1>v[1].x1 then
xm1:=v[3].x1;
xm2:=v[1].x2;
if v[3].x2<v[1].x2 then
xm2:=v[3].x2;

ym1:=v[1].y1;
if v[3].y1>v[1].y1 then
ym1:=v[3].y1;
ym2:=v[1].y2;
if v[3].y2<v[1].y2 then
ym2:=v[3].y2;
ar:=calculeaza2(xm1,xm2,ym1,ym2);
pe:=calculeaza1(xm1,xm2,ym1,ym2);
dec(att,ar);
dec(pt,pe);
end;






procedure intersectie1;
var  xm1,ym1,xm2,ym2,ar,pe:longint;
begin
xm1:=v[1].x1;
if v[2].x1>v[1].x1 then
xm1:=v[2].x1;
xm2:=v[1].x2;
if v[2].x2<v[1].x2 then
xm2:=v[2].x2;


ym1:=v[1].y1;
if v[2].y1>v[1].y1 then
ym1:=v[2].y1;
ym2:=v[1].y2;
if v[2].y2<v[1].y2 then
ym2:=v[2].y2;
a1:=xm1;
a2:=xm2;
b1:=ym1;
b2:=ym2;
ar:=calculeaza2(xm1,xm2,ym1,ym2);
pe:=calculeaza1(xm1,xm2,ym1,ym2);
dec(att,ar);
dec(pt,pe);
end;







begin
assign(input,'reuniune.in');reset(input);
assign(output,'reuniune.out');rewrite(output);
att:=0;
pt:=0;
for i:=1 to 3 do begin
read(v[i].x1,v[i].y1,v[i].x2,v[i].y2);
l1:=abs(v[i].x2-v[i].x1);
l2:=abs(v[i].y2-v[i].y1);
v[i].p:=2*(l1+l2);
v[i].a:=l1*l2;
inc(att,v[i].a);
inc(pt,v[i].p);
end;
intersectie1;
intersectie2;
intersectie3;
intersectie4;
write(att,' ',pt);
close(output);
end.