Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- const
- MAXIN = 9;
- var
- x, y, x1, y1, k, min, first_int, x2, y2: integer;
- a: array [0..MAXIN, 0..MAXIN] of integer;
- bol: array [0..MAXIN, 0..MAXIN] of boolean;
- procedure clean();
- var
- i, j: integer;
- begin
- for i := 1 to MAXIN do
- for j := 1 to MAXIN do
- begin
- a[i][j] := 0;
- bol[i][j] := true;
- end;
- end;
- procedure rec(x, y: integer);
- begin
- if (x in [0..9]) and (y in [0..9]) and (bol[x][y]) then
- begin
- bol[x][y] := false;
- if (x = x1) and (y = y1) then
- if (min < first_int) then
- begin
- k := 1;
- first_int := min;
- writeln(x, ' ', y);
- end
- else
- if (min = first_int) then
- inc(k)
- else
- else
- begin
- inc(min);
- rec(x + 2, y + 1);
- rec(x + 2, y - 1);
- rec(x - 2, y + 1);
- rec(x - 2, y - 1);
- rec(x + 1, y + 2);
- rec(x + 1, y - 2);
- rec(x - 1, y + 2);
- rec(x - 1, y - 2);
- end;
- end;
- end;
- begin
- readln(x2, y2, x1, y1);
- clean();
- min := 0;
- first_int := MAXINT;
- a[x2][y2] := 1;
- k := 1;
- rec(x2, y2);
- if (k <> 0) then
- writeln(k, ' ', first_int)
- else
- writeln(-1);
- readln;
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment