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

Обсуждение задачи 1022. Генеалогическое дерево

Why so complicated!!!!!
Послано Juri Krainjukov 29 ноя 2002 01:21
Look at this solution. It's very easy and it works!!!!!!!

var
   n:integer;
   i,j,c:integer;
   a:array[1..100,1..100] of boolean;
   b:array[1..100] of boolean;
   s:array[1..100] of integer;

procedure ds(x:integer);
var
    i:integer;
begin
   b[x]:=false;
   for I:=1 to n do
      if (a[x,i]) and (b[i]) then ds(i);
   dec(c);
   s[c]:=x;
end;

begin
   for I:=1 to 100 do for J:=1 to 100 do a[i,j]:=false;
   for i:=1 to 100 do b[i]:=true;

   readln(n);

   for I:=1 to n do begin
      repeat
          read(c);
         if c<>0 then a[i,c]:=true;
      until c=0
   end;

   c:=n+1;

   for I:=1 to n do if b[i] then ds(i);
   for i:=1 to n do begin
      write(s[i]);
      if i<n then write(' ');
   end;

end.
That problem is very easy i don't know why u publish such solution :) (-)
Послано Miguel Angel 29 ноя 2002 07:08
> Look at this solution. It's very easy and it works!!!!!!!
>
> var
>    n:integer;
>    i,j,c:integer;
>    a:array[1..100,1..100] of boolean;
>    b:array[1..100] of boolean;
>    s:array[1..100] of integer;
>
> procedure ds(x:integer);
> var
>     i:integer;
> begin
>    b[x]:=false;
>    for I:=1 to n do
>       if (a[x,i]) and (b[i]) then ds(i);
>    dec(c);
>    s[c]:=x;
> end;
>
> begin
>    for I:=1 to 100 do for J:=1 to 100 do a[i,j]:=false;
>    for i:=1 to 100 do b[i]:=true;
>
>    readln(n);
>
>    for I:=1 to n do begin
>       repeat
>           read(c);
>          if c<>0 then a[i,c]:=true;
>       until c=0
>    end;
>
>    c:=n+1;
>
>    for I:=1 to n do if b[i] then ds(i);
>    for i:=1 to n do begin
>       write(s[i]);
>       if i<n then write(' ');
>    end;
>
> end.
So give shorter solution :-)
Послано Juri Krainjukov 30 ноя 2002 19:34
if you shorter solution,please, post it here. I just don't know how
to make it smaller.
I just told you "this problem is easy", my solution is equals "in length" to yours, the difference is that i solved this one a lot of time before :) (-)
Послано Miguel Angel 1 дек 2002 02:03
> if you shorter solution,please, post it here. I just don't know how
> to make it smaller.
I think If I started solving problems from this site earlier than several weeks ago I would also have already solved it :-)
Послано Juri Krainjukov 1 дек 2002 03:12
Yeah, but my point is that this webboard is for questions only :| (-)
Послано Miguel Angel 1 дек 2002 05:19
>