ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1008. Кодирование изображений

what's wrong with my program?
Послано Sum 1 4 фев 2003 11:03
const
     f: array [1..4, 1..2] of integer =
        ((1, 0), (0, -1), (-1, 0), (0, 1));
     str: array [1..4] of char = ('R', 'B', 'L', 'T');

var
   x, y, p: array [1..10] of longint;
   n, n0, i, j, k, head, foot, x0, y0, q: longint;
   ok: boolean;
   s: string;

begin
     read(n);
     if eoln then begin
        for i := 1 to n do read(x[i], y[i]);
        head := 0;
        foot := 1;
        p[1] := 1;
        writeln(x[1], ' ', y[1]);
        repeat
              inc(head);
              for i := 1 to 4 do begin
                  x0 := x[p[head]] + f[i, 1];
                  y0 := y[p[head]] + f[i, 2];
                  j := 1;
                  while (j <= n) and ((x0 <> x[j]) or (y0 <> y[j]))
do inc(j);
                  if j > n then continue;
                  ok := true;
                  for k := 1 to foot do if j = p[k] then begin ok :=
false; break; end;
                  if ok then begin
                     write(str[i]);
                     inc(foot);
                     p[foot] := j;
                  end;
              end;
              if head = n then writeln('.') else writeln(',');
        until head = n;
     end
     else begin
          x[1] := n;
          readln(y[1]);
          n0 := 1;
          n := 0;
          repeat
                inc(n);
                readln(s);
                for i := 1 to length(s) - 1 do
                    for j := 1 to 4 do
                        if s[i] = str[j] then begin
                           inc(n0);
                           x[n0] := x[n] + f[j, 1];
                           y[n0] := y[n] + f[j, 2];
                           break;
                        end;
                if s[length(s)] = '.' then break;
          until false;
          for i := 1 to n - 1 do begin
              q := i;
              for j := i + 1 to n do
                  if (x[j] < x[q]) or ((x[j] = x[q]) and (y[j] < y
[q])) then q := j;
              if q <> i then begin
                 x0 := x[q];
                 y0 := y[q];
                 x[q] := x[i];
                 y[q] := y[i];
                 x[i] := x0;
                 y[i] := y0;
              end;
          end;
          writeln(n);
          for i := 1 to n do writeln(x[i], ' ', y[i]);
     end;
end.
Re: what's wrong with my program?
Послано Fechete Dan Ionut[dany] 4 фев 2003 12:11
> const
>      f: array [1..4, 1..2] of integer =
>         ((1, 0), (0, -1), (-1, 0), (0, 1));
>   //   str: array [1..4] of char = ('R', 'B', 'L', 'T');
    this is clockwise order;
    the problem statement sais anticlockwise RTLB;
>
> var
>    x, y, p: array [1..10] of longint;
>    n, n0, i, j, k, head, foot, x0, y0, q: longint;
>    ok: boolean;
>    s: string;
>
> begin
>      read(n);
>      if eoln then begin
>         for i := 1 to n do read(x[i], y[i]);
>         head := 0;
>         foot := 1;
>         p[1] := 1;
>         writeln(x[1], ' ', y[1]);
>         repeat
>               inc(head);
>               for i := 1 to 4 do begin
>                   x0 := x[p[head]] + f[i, 1];
>                   y0 := y[p[head]] + f[i, 2];
>                   j := 1;
>                   while (j <= n) and ((x0 <> x[j]) or (y0 <> y[j]))
> do inc(j);
>                   if j > n then continue;
>                   ok := true;
>                   for k := 1 to foot do if j = p[k] then begin
ok :=
> false; break; end;
>                   if ok then begin
>                      write(str[i]);
>                      inc(foot);
>                      p[foot] := j;
>                   end;
>               end;
>               if head = n then writeln('.') else writeln(',');
>         until head = n;
>      end
>      else begin
>           x[1] := n;
>           readln(y[1]);
>           n0 := 1;
>           n := 0;
>           repeat
>                 inc(n);
>                 readln(s);
>                 for i := 1 to length(s) - 1 do
>                     for j := 1 to 4 do
>                         if s[i] = str[j] then begin
>                            inc(n0);
>                            x[n0] := x[n] + f[j, 1];
>                            y[n0] := y[n] + f[j, 2];
>                            break;
>                         end;
>                 if s[length(s)] = '.' then break;
>           until false;
>           for i := 1 to n - 1 do begin
>               q := i;
>               for j := i + 1 to n do
>                   if (x[j] < x[q]) or ((x[j] = x[q]) and (y[j] < y
> [q])) then q := j;
>               if q <> i then begin
>                  x0 := x[q];
>                  y0 := y[q];
>                  x[q] := x[i];
>                  y[q] := y[i];
>                  x[i] := x0;
>                  y[i] := y0;
>               end;
>           end;
>           writeln(n);
>           for i := 1 to n do writeln(x[i], ' ', y[i]);
>      end;
> end.
Re: what's wrong with my program?
Послано Sum 1 4 фев 2003 21:53
> const
>      f: array [1..4, 1..2] of integer =
>         ((1, 0), (0, -1), (-1, 0), (0, 1));
>   //   str: array [1..4] of char = ('R', 'B', 'L', 'T');
>     this is clockwise order;
>     the problem statement sais anticlockwise RTLB;

I changed it into RTLB and also get WA!!!
I know what's wrong!!!There are more than 10 black pixels!!!
Послано Sum 1 5 мар 2003 18:35
> const
>      f: array [1..4, 1..2] of integer =
>         ((1, 0), (0, -1), (-1, 0), (0, 1));
>      str: array [1..4] of char = ('R', 'B', 'L', 'T');
>
> var
>    x, y, p: array [1..10] of longint;
>    n, n0, i, j, k, head, foot, x0, y0, q: longint;
>    ok: boolean;
>    s: string;
>
> begin
>      read(n);
>      if eoln then begin
>         for i := 1 to n do read(x[i], y[i]);
>         head := 0;
>         foot := 1;
>         p[1] := 1;
>         writeln(x[1], ' ', y[1]);
>         repeat
>               inc(head);
>               for i := 1 to 4 do begin
>                   x0 := x[p[head]] + f[i, 1];
>                   y0 := y[p[head]] + f[i, 2];
>                   j := 1;
>                   while (j <= n) and ((x0 <> x[j]) or (y0 <> y[j]))
> do inc(j);
>                   if j > n then continue;
>                   ok := true;
>                   for k := 1 to foot do if j = p[k] then begin
ok :=
> false; break; end;
>                   if ok then begin
>                      write(str[i]);
>                      inc(foot);
>                      p[foot] := j;
>                   end;
>               end;
>               if head = n then writeln('.') else writeln(',');
>         until head = n;
>      end
>      else begin
>           x[1] := n;
>           readln(y[1]);
>           n0 := 1;
>           n := 0;
>           repeat
>                 inc(n);
>                 readln(s);
>                 for i := 1 to length(s) - 1 do
>                     for j := 1 to 4 do
>                         if s[i] = str[j] then begin
>                            inc(n0);
>                            x[n0] := x[n] + f[j, 1];
>                            y[n0] := y[n] + f[j, 2];
>                            break;
>                         end;
>                 if s[length(s)] = '.' then break;
>           until false;
>           for i := 1 to n - 1 do begin
>               q := i;
>               for j := i + 1 to n do
>                   if (x[j] < x[q]) or ((x[j] = x[q]) and (y[j] < y
> [q])) then q := j;
>               if q <> i then begin
>                  x0 := x[q];
>                  y0 := y[q];
>                  x[q] := x[i];
>                  y[q] := y[i];
>                  x[i] := x0;
>                  y[i] := y0;
>               end;
>           end;
>           writeln(n);
>           for i := 1 to n do writeln(x[i], ' ', y[i]);
>      end;
> end.
Re: I know what's wrong!!!There are more than 10 black pixels!!!
Послано Liu Guyue 12 ноя 2005 19:40
i change 5 to 10 ..

but i still wa...
at this time i got wa on test 1
before i just got wa on test 2....

-____-b