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

Общий форум

I use DFS to solve 1176 and get WA! I can't find test on which my program fails. Please, help me ! ! !(+)
Послано Nazarov Denis (nsc2001@rambler.ru) 16 фев 2002 22:17
Program t1176;

Const MaxN = 1000;

Type  Mas  = array[1..MaxN,1..MaxN div 2]of byte;

Var   G        : Mas;
      N,A,i,j  : longint;
      Cur      : longint;
      Path     : array[1..MaxN*10]of integer;
      b        : byte;
      label    New,ENew;

Function GetV(i,j : integer) : byte;
var t,s,fi,se : integer;
 begin
  s:=(j div 2)+(j mod 2);
  t:=g[i,s];
  fi:=t mod 2;
  se:=(t-fi) div 2;
  if j mod 2=0 then GetV:=fi else GetV:=se;
 end;

Procedure SetV(i,j : integer;v : byte);
var t,s,fi,se : integer;
 begin
  s:=(j div 2)+(j mod 2);
  t:=g[i,s];
  fi:=t mod 2;
  se:=(t-fi) div 2;
  if j mod 2=0 then fi:=v else se:=v;
  g[i,s]:=fi+se*2;
 end;

begin
 Read(N,A);
 for i:=1 to N do
  for j:=1 to N do begin
    read(b);
    SetV(i,j,b);
   end;
 for i:=1 to N do SetV(i,i,1);
 Path[1]:=A;
 Cur:=1;
New:
  Cur:=Cur+1;
  for i:=1 to N do
    if (GetV(Path[Cur-1],i)=0)or(GetV(i,Path[Cur-1])=0) then begin
     Path[Cur]:=i;
     SetV(i,Path[Cur-1],1);
     SetV(Path[Cur-1],i,1);
     Writeln(Path[Cur-1],' ',Path[Cur]);
     goto New;
    end;
  Cur:=Cur-2;
  if Cur=0 then goto ENew;
  Writeln(Path[Cur+1],' ',Path[Cur]);
  goto New;
ENew:
end.
Re: I use DFS to solve 1176 and get WA! I can't find test on which my program fails. Please, help me ! ! !(+)
Послано Mephistos 17 фев 2002 09:56
7 1
1 0 1 1 1 1 1
1 1 0 1 0 1 1
1 1 1 0 1 1 1
0 1 1 1 1 1 1
1 1 1 1 1 0 1
1 1 1 1 1 1 0
1 0 1 1 1 1 1