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

Обсуждение задачи 1642. Одномерный лабиринт

WA 1
Послано rodge(Vologda ML) 18 окт 2009 17:11
var
  a : array[-1000..0] of integer;
  b : array[0..1000] of integer;
  n, i, j, k, l, m, u, x : integer;
  c : array[1..100] of integer;
begin
  read(n, x);
  k := 0;
  m := 0;
  l := 0;
  u := 0;
  j := 0;
  i := 0;
  for i := 1 to n do begin
    read(c[i]);
    if c[i] >= 0 then b[c[i]] := 1 else a[c[i]] := 1;
  end;
  if b[0] = 1 then u := 1;
  if x = 0 then begin
    k := 0;
    m := 0;
  end;
  if x < 0 then begin
    for i := x to -1 do begin
      if a[i] = 1 then begin
        u := 1;
        break;
      end;
    end;
    if i = 0 then begin
      for j := 0 downto x do begin
        inc(m);
      end;
      m := m - 1;
      repeat
        inc(k);
      until b[k] = 1;
      k := 2 * k + m;
      end;
  end;
  if x > 0 then begin
      for i := 0 to x do begin
        if(b[i]) = 1 then begin
          u := 1;
          break;
        end;
      end;
      if i = x + 1 then begin
        for j := 0 to x do begin
          inc(k);
        end;
        k := k - 1;
        repeat
          inc(m);
          dec(l);
        until a[l] = 1;
        m := 2 * m + k
      end;
    end;
    if u = 1 then writeln('Impossible') else
    writeln(k,' ', m);
    readln;
    readln;
end.
my code it is work for different numbers and tests (my tests( but WA 1) plese, who can help me?
Re: WA 1
Послано Oleg Strekalovsky aka OSt [Vologda SPU] 18 окт 2009 18:14
I solved this problem by emulation.
I have WA 1 too. Problem was with calculation distance. They some times became negative. When i add function abs() for every places, where was calculation distances - i got AC


Edited by author 18.10.2009 18:20
Re: WA 1
Послано rodge(Vologda ML) 8 ноя 2009 13:51
var
  a : array[-1000..0] of integer;
  b : array[0..1000] of integer;
  n, i, j, k, l, m, u, x : integer;
  c : array[1..100] of integer;
begin
  read(n, x);
  k := 0;
  m := 0;
  l := 0;
  u := 0;
  j := 0;
  i := 0;
  for i := 1 to n do begin
    read(c[i]);
    if c[i] > 0 then b[c[i]] := 1 else a[c[i]] := 1;
  end;
  if x < 0 then begin
    for i := x to -1 do begin
      if a[i] = 1 then begin
        u := 1;
        break;
      end;
    end;
    if i = 0 then begin
      j := 0;
      while (k>x) do begin
        dec(k);
      end;
      k := abs(k);
      while (b[j]<>1) and (abs(j)<1000) do begin
        inc(m);
        inc(j);
      end;
      m := m * 2 + k;
    end;
  end;
  if x > 0 then begin
    for i := 0 to x do begin
      if(b[i]) = 1 then begin
        u := 1;
        break;
      end;
    end;
    if i = x + 1 then begin
      j := 0;
      while m < x do begin
        inc(m);
      end;
      while (a[j]<>1) and (abs(j)<1000) do begin
        inc(k);
        dec(j);
      end;
      k := k * 2 + m;
    end;
  end;
  if u = 1 then writeln('Impossible') else begin
    write(m,' ',k);
  end;
  readln;readln;
end.
correct my solution but WA1 it's very bad ((( who knows test 1?

Edited by author 08.11.2009 14:04
Re: WA 1
Послано rodge(Vologda ML) 8 ноя 2009 14:05
all tests is right may be I wrong in output? can somebody help me and sorry for my bad english
Re: WA 1
Послано unlucky [Vologda SPU] 8 ноя 2009 15:54
rodge(Vologda ML) писал(a) 8 ноября 2009 13:51
var
  a : array[-1000..0] of integer;
  b : array[0..1000] of integer;
  n, i, j, k, l, m, u, x : integer;
  c : array[1..100] of integer;
begin
  read(n, x);
  k := 0;
  m := 0;
  l := 0;
  u := 0;
  j := 0;
  i := 0;
  for i := 1 to n do begin
    read(c[i]);
    if c[i] > 0 then b[c[i]] := 1 else a[c[i]] := 1;
  end;
  if x < 0 then begin
    for i := x to -1 do begin
      if a[i] = 1 then begin
        u := 1;
        break;
      end;
    end;
    if i = 0 then begin
      j := 0;
      while (k>x) do begin
        dec(k);
      end;
      k := abs(k);
      while (b[j]<>1) and (abs(j)<1000) do begin
        inc(m);
        inc(j);
      end;
      m := m * 2 + k;
    end;
  end;
  if x > 0 then begin
    for i := 0 to x do begin
      if(b[i]) = 1 then begin
        u := 1;
        break;
      end;
    end;
    if i = x + 1 then begin
      j := 0;
      while m < x do begin
        inc(m);
      end;
      while (a[j]<>1) and (abs(j)<1000) do begin
        inc(k);
        dec(j);
      end;
      k := k * 2 + m;
    end;
  end;
  if u = 1 then writeln('Impossible') else begin
    write(m,' ',k);
  end;
  readln;readln;
end.
correct my solution but WA1 it's very bad ((( who knows test 1?

Edited by author 08.11.2009 14:04
Your code is very crazy :)
1. He get wrong answer for demo test
2.
if x < 0 then begin
    for i := x to -1 do begin (*)
      if a[i] = 1 then begin
        u := 1;
        break;
      end;
    end;
    if i = 0 then begin (**)
How do you think - it is possible to go get TRUE in condition (**) if cycle condition (**) is that?

And the same bug in

    for i := 0 to x do begin (*)
      if(b[i]) = 1 then begin
        u := 1;
        break;
      end;
    end;
    if i = x + 1 then begin (**)

More help only via e-mail.


Edited by author 08.11.2009 15:55
Re: WA 1
Послано rodge(Vologda ML) 20 янв 2010 22:13
Thank you )))
I am thinking and rewriting me programm for 10 minutes now )))
and got AC it's amazing )))