Cod sursa(job #147504)

Utilizator valytgjiu91stancu vlad valytgjiu91 Data 3 martie 2008 00:04:55
Problema Reuniune Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 4.4 kb
var f,g:text;
a:array[1..3] of record
                 x1,y1,x2,y2,p,s:longint;
                 end;
i:byte;
s1,s2,s,p,s13,p13,p12,p1,p2,s12,p23,s23:longint;
begin
assign(f,'reuniune.in');
reset(f);
for i:=1 to 3 do
begin
readln(f,a[i].x1,a[i].y1,a[i].x2,a[i].y2);
a[i].p:=abs(2*(a[i].x2-a[i].x1))+abs(2*(a[i].y2-a[i].y1));
a[i].s:=(a[i].x2-a[i].x1)*(a[i].y2-a[i].y1);
end;
if (a[1].x1<a[2].x1) and (a[2].x1<a[1].x2) and(a[1].y1<a[2].y1) and(a[2].y1<a[1].y2) then
                                         begin
                                         if a[2].x2>a[1].x2 then p1:=a[1].x2-a[2].x1
                                                        else p1:=a[2].x2-a[2].x1;
                                         if a[2].y2>a[1].y2 then p2:=a[1].y2-a[2].y1
                                                        else p2:=a[2].y2-a[2].y1;
                                         s12:=p1*p2;
                                         p12:=abs(2*p1)+abs(2*p2);
                                         end;
if (a[1].x1<a[2].x2) and (a[2].x2<a[1].x2) and(a[1].y1<a[2].y2) and(a[2].y2<a[1].y2) then
                                         begin
                                         if a[2].x1>a[1].x1 then p1:=a[2].x2-a[2].x1
                                                        else p1:=a[2].x2-a[1].x1;
                                         if a[2].y1>a[1].y1 then p2:=a[2].y2-a[2].y1
                                                        else p2:=a[2].y2-a[1].y1;
                                         s12:=p1*p2;
                                         p12:=abs(2*p1)+abs(2*p2);
                                         end;
{}
if (a[2].x1<a[3].x1) and (a[3].x1<a[2].x2) and(a[2].y1<a[3].y1) and(a[3].y1<a[2].y2) then
                                         begin
                                         if a[3].x2>a[2].x2 then p1:=a[2].x2-a[3].x1
                                                        else p1:=a[3].x2-a[3].x1;
                                         if a[3].y2>a[2].y2 then p2:=a[2].y2-a[3].y1
                                                        else p2:=a[3].y2-a[3].y1;
                                         s23:=p1*p2;
                                         p23:=abs(2*p1)+abs(2*p2);
                                         end;
if (a[2].x1<a[3].x2) and (a[3].x2<a[2].x2) and(a[2].y1<a[3].y2) and(a[3].y2<a[2].y2) then
                                         begin
                                         if a[3].x1>a[2].x1 then p1:=a[3].x2-a[3].x1
                                                        else p1:=a[3].x2-a[2].x1;
                                         if a[3].y1>a[2].y1 then p2:=a[3].y2-a[2].y1
                                                        else p2:=a[3].y2-a[2].y1;
                                         s23:=p1*p2;
                                         p23:=abs(2*p1)+abs(2*p2);
                                         end;
{}
if (a[1].x1<a[3].x1) and (a[3].x1<a[1].x2) and(a[1].y1<a[3].y1) and(a[3].y1<a[1].y2) then
                                         begin
                                         if a[3].x2>a[1].x2 then p1:=a[1].x2-a[3].x1
                                                        else p1:=a[3].x2-a[3].x1;
                                         if a[3].y2>a[1].y2 then p2:=a[1].y2-a[3].y1
                                                        else p2:=a[3].y2-a[3].y1;
                                         s13:=p1*p2;
                                         p13:=abs(2*p1)+abs(2*p2);
                                         end;
if (a[1].x1<a[3].x2) and (a[3].x2<a[1].x2) and(a[1].y1<a[3].y2) and(a[3].y2<a[1].y2) then
                                         begin
                                         if a[3].x1>a[1].x1 then p1:=a[3].x2-a[3].x1
                                                        else p1:=a[3].x2-a[1].x1;
                                         if a[3].y1>a[1].y1 then p2:=a[3].y2-a[3].y1
                                                        else p2:=a[3].y2-a[1].y1;
                                         s13:=p1*p2;
                                         p13:=abs(2*p1)+abs(2*p2);
                                         end;
{}
s:=a[1].s+a[2].s+a[3].s-s12-s23-s13;
p:=a[1].p+a[2].p+a[3].p-p12-p23-p13;
s1:=abs(abs(s12-s23)-s13);
p1:=abs(abs(p12-p23)-p13);
s:=s+s1;
p:=p+p1;
assign(g,'reuniune.out');
rewrite(g);
writeln(g,s,' ',p);
close(g);
end.