Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program zad_1;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- type
- t = array [1..4] of integer;
- var
- a, b, c, d: t;
- n, i, j, cnt, flag, h, s, f, max1, maxi, min1, mini: integer;
- function full(var a, b, c, d: t): integer;
- begin
- maxi := a[1];
- for i := 2 to 4 do
- if (a[i] > maxi) then
- maxi := a[i];
- for i := 1 to 4 do
- if (b[i] > maxi) then
- maxi := b[i];
- for i := 1 to 4 do
- if (c[i] > maxi) then
- maxi := c[i];
- for i := 1 to 4 do
- if (d[i] > maxi) then
- maxi := d[i];
- full := maxi;
- end;
- function empty(var a, b, c, d: t): integer;
- begin
- mini := a[1];
- for i := 2 to 4 do
- if (a[i] < mini) then
- maxi := a[i];
- for i := 1 to 4 do
- if (b[i] < mini) then
- maxi := b[i];
- for i := 1 to 4 do
- if (c[i] < mini) then
- maxi := c[i];
- for i := 1 to 4 do
- if (d[i] < mini) then
- maxi := d[i];
- empty := mini;
- end;
- begin
- readln(a[1], a[2], a[3], a[4]);
- readln(b[1], b[2], b[3], b[4]);
- readln(c[1], c[2], c[3], c[4]);
- readln(d[1], d[2], d[3], d[4]);
- max1 := full(a, b, c, d);
- min1 := empty(a, b, c, d);
- s := 0;
- f := 0;
- h := 0;
- for i := min1 to max1 do begin
- if (a[3] = i) then begin
- dec(s);
- inc(h);
- end;
- if (b[3] = i) then begin
- dec(s);
- inc(h);
- end;
- if (c[3] = i) then begin
- dec(s);
- inc(h);
- end;
- if (d[3] = i) then begin
- dec(s);
- inc(h);
- end;
- if (h = 2) and (s = 0) then begin
- writeln('Vertical');
- writeln(i);
- halt;
- end;
- if (h = 2) and (s <> 0) or (h > 2) or (s > 2) then
- break;
- if (a[1] = i) then
- inc(s);
- if (b[1] = i) then
- inc(s);
- if (c[1] = i) then
- inc(s);
- if (d[1] = i) then
- inc(s);
- end;
- s := 0;
- f := 0;
- h := 0;
- for i := min1 to max1 do begin
- if (a[4] = i) then begin
- dec(s);
- inc(h);
- end;
- if (b[4] = i) then begin
- dec(s);
- inc(h);
- end;
- if (c[4] = i) then begin
- dec(s);
- inc(h);
- end;
- if (d[4] = i) then begin
- dec(s);
- inc(h);
- end;
- if (h = 2) and (s = 0) then begin
- writeln('Horizontal');
- writeln(i);
- halt;
- end;
- if (h = 2) and (s <> 0) or (h > 2) or (s > 2) then
- break;
- if (a[2] = i) then
- inc(s);
- if (b[2] = i) then
- inc(s);
- if (c[2] = i) then
- inc(s);
- if (d[2] = i) then
- inc(s);
- end;
- writeln('Impossible');
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement