Cod sursa(job #674918)

Utilizator andreifirstCioara Andrei Ioan andreifirst Data 6 februarie 2012 21:24:09
Problema Reuniune Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.93 kb
var v:array [1..7, 1..4] of int64;
    l1, l2:int64;
    p, a:array [1..7] of int64;
    i, j:longint;
    f, g:text;

function min (x, y:longint):longint;
  begin
  if x<y then min:=x else min := y;
  end;

function max (x, y:longint):longint;
  begin
  if x>y then max := x else max :=y;
  end;

procedure reu (x1, x2, x3, x4, y1, y2, y3, y4:int64; var z1, z2, z3, z4:int64);
  begin
  z1:=max(x1, y1);
  z2:=max(x2, y2);
  z3:=min(x3, y3);
  z4:=min(x4, y4);
  end;

begin
assign (f, 'reuniune.in'); reset (f);
assign (g, 'reuniune.out'); rewrite (g);

for i := 1 to 3 do for j := 1 to 4 do read (f, v[i, j]);

reu(v[1, 1], v[1, 2], v[1, 3], v[1, 4], v[2, 1], v[2, 2], v[2, 3], v[2, 4], v[4, 1], v[4, 2], v[4, 3], v[4, 4]);
reu(v[2, 1], v[2, 2], v[2, 3], v[2, 4], v[1, 1], v[1, 2], v[1, 3], v[1, 4], v[4, 1], v[4, 2], v[4, 3], v[4, 4]);

reu(v[1, 1], v[1, 2], v[1, 3], v[1, 4], v[3, 1], v[3, 2], v[3, 3], v[3, 4], v[5, 1], v[5, 2], v[5, 3], v[5, 4]);
reu(v[3, 1], v[3, 2], v[3, 3], v[3, 4], v[1, 1], v[1, 2], v[1, 3], v[1, 4], v[5, 1], v[5, 2], v[5, 3], v[5, 4]);

reu(v[2, 1], v[2, 2], v[2, 3], v[2, 4], v[3, 1], v[3, 2], v[3, 3], v[3, 4], v[6, 1], v[6, 2], v[6, 3], v[6, 4]);
reu(v[3, 1], v[3, 2], v[3, 3], v[3, 4], v[2, 1], v[2, 2], v[2, 3], v[2, 4], v[6, 1], v[6, 2], v[6, 3], v[6, 4]);

reu(v[4, 1], v[4, 2], v[4, 3], v[4, 4], v[3, 1], v[3, 2], v[3, 3], v[3, 4], v[7, 1], v[7, 2], v[7, 3], v[7, 4]);
reu(v[3, 1], v[3, 2], v[3, 3], v[3, 4], v[4, 1], v[4, 2], v[4, 3], v[4, 4], v[7, 1], v[7, 2], v[7, 3], v[7, 4]);

for i := 1 to 7 do
  begin
  l1:=v[i, 3]-v[i, 1]; l2:=v[i, 4]-v[i, 2];
  if (l1>=0) and (l2>=0) then
    begin
    a[i]:=l1*l2; p[i]:=l1+l2+l1+l2;
    end
                        else
    begin
    a[i]:=0; p[i]:=0;
    end;
  end;

write (g, a[1]+a[2]+a[3]-a[4]-a[5]-a[6]+a[7], ' ');
write (g, p[1]+p[2]+p[3]-p[4]-p[5]-p[6]+p[7]);

for i := 1 to 7 do writeln (a[i]);

close (f); close (g);
end.