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

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

WA on Test 5!
Послано mj256 11 июл 2007 19:16
I have made many inputs and check the outputs by hand,and I have't got any wrong answer,BUT I got WA on Test#5!
Would you plese help me ?Give Some Test to Me?
[code]
program p1008;
const
  dx:array[1..4]of integer=(1,0,-1,0);
  dy:array[1..4]of integer=(0,1,0,-1);
type
  xy=record
    y,x:longint;
  end;


var
  fx,fy,k,mode,n:longint;
  g:array[0..11,0..11]of boolean;
  order:array[1..100]of string;

  procedure init;
  var
    a,b,i:longint;
    s:string;
  begin
    read(n);
    if eoln then mode:=1
    else begin mode:=2;readln(fy);fx:=n;end;


    fillchar(g,sizeof(g),false);
    case mode of
    1:begin
        for i:=1 to n do
        begin
          readln(a,b);
          g[b,a]:=true;
        end;
      end;
    2:begin
        k:=0;
        while not seekeof do
        begin
          inc(k);
          readln(order[k]);
        end;
      end;
    end;
  end;


  procedure bfs(y,x:longint);
  var
    tx,ty,h,t,i,j:longint;
    d:array[1..100] of xy;
    s:string;
  begin
    writeln(x,' ',y);
    h:=1;t:=1;d[1].y:=y;d[1].x:=x;g[y,x]:=false;
    repeat
      s:='';

      for i:=1 to 4 do
      begin
        tx:=d[h].x+dx[i];
        ty:=d[h].y+dy[i];
        if g[ty,tx] then
        begin
          case i of
          1:s:=s+'R';
          2:s:=s+'T';
          3:s:=s+'L';
          4:s:=s+'B';
          end;
          inc(t);
          d[t].y:=ty;d[t].x:=tx;
          g[ty,tx]:=false;
        end;
      end;
      if (h=t)and(s='')then s:=s+'.' else s:=s+',';
      writeln(s);
      inc(h);
    until h>t;
  end;


  procedure main1;
  var
    i,j:longint;
  begin
    for i:=1 to n do
      for j:=1 to n do
      begin
        if g[j,i] then begin bfs(j,i);close(output);halt;end;
      end;
  end;

  procedure main2;
  var
    tx,ty,h,t,l,i,j:longint;
    d:array[1..100]of xy;
    v:array[0..11,0..11]of boolean;
  begin
    g[fy,fx]:=true;
    h:=1;t:=1;d[1].y:=fy;d[1].x:=fx;
    fillchar(v,sizeof(v),false);
    v[fy,fx]:=true;
    g[fy,fx]:=true;
    for l:=1 to k do
    begin
      for i:=1 to length(order[l])-1 do
      begin
        case order[l][i] of
        'R':begin
              tx:=d[h].x+dx[1];
              ty:=d[h].y+dy[1];
            end;
        'T':begin
              tx:=d[h].x+dx[2];
              ty:=d[h].y+dy[2];
           end;
        'L':begin
              tx:=d[h].x+dx[3];
              ty:=d[h].y+dy[3];
            end;
        'B':begin
              tx:=d[h].x+dx[4];
              ty:=d[h].y+dy[4];
            end;
        end;
        if not v[ty,tx] then
        begin
          inc(t);d[t].x:=tx;d[t].y:=ty;
          g[ty,tx]:=true;
          v[ty,tx]:=true;
        end;
      end;
      inc(h);
    end;

    writeln(h-1);
    for i:=1 to 10 do
      for j:=1 to 10 do
        if g[j,i] then writeln(i,' ',j);
  end;

begin
  assign(output,'test.out');rewrite(output);
  assign(input,'test.in');reset(input);
  init;
  if mode=1 then main1 else main2;
  close(output);
  close(input);
end.

[/code]
Re: WA on Test 5!
Послано cloudygooose 4 июл 2008 11:59
IF there's only one point,you should output:
2 3
.
not 2 3.