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

Обсуждение задачи 1173. Lazy Snail

Why I get WA? Pelase, help me!!!!!!!
Послано Happy New Year! Russia. 31 дек 2001 19:02
My program:

Program t1173;{$N+}

Const Eps=1E-20;

Var Snail      :array[0..1000]of record X,Y,W :extended; ID :longint;
Use:boolean end;
    PredW,MinW :extended;
    i,N,CurI,j :longint;

Function GetW(CurX,CurY:extended):extended;
Var CurW,tgW,absW      :extended;
 begin
  if Abs(CurX)<Eps then begin
   if CurY>0 then CurW:=90;
   if CurY<=0 then CurW:=270;
  end else
  if Abs(CurY)<Eps then begin
   if CurX>0 then CurW:=0;
   if CurX<=0 then CurW:=180;
  end else begin
   tgW:=abs(CurY/CurX);
   absW:=ArcTan(tgW)*360/(2*Pi);
   if (CurX>0)and(CurY>0) then CurW:=absW else
   if (CurX>0)and(CurY<0) then CurW:=360-absW else
   if (CurX<0)and(CurY>0) then CurW:=180-absW else
   if (CurX<0)and(CurY<0) then CurW:=180+absW;
  end;
  GetW:=CurW;
 end;

begin
Snail[0].ID:=0;
Read(Snail[0].X,Snail[0].Y);
Read(N);
for i:=1 to N do Read(Snail[i].X,Snail[i].Y,Snail[i].ID);
for i:=1 to N do Snail[i].W:=GetW(Snail[i].X-Snail[0].X,Snail[i].Y-
Snail[0].Y);
for i:=1 to N do Snail[i].Use:=false;
PredW:=361;
Writeln(0);
for j:=1 to N do begin
 MinW:=-1;
 CurI:=0;
 for i:=1 to N do
  if not(Snail[i].Use) then
   if (Snail[i].W>MinW)and(PredW>Snail[i].W) then begin
    MinW:=Snail[i].W;
    CurI:=i;
   end;
 PredW:=MinW;
 Snail[CurI].Use:=true;
 Writeln(Snail[CurI].ID);
end;
Writeln(0);
end.
Your solution is almost correct, but...
Послано shitty.Mishka 31 дек 2001 20:42
there might be some problems with tests like this:
0 0
3
2 0 1
1 1 2
1 -1 3
I think you've caught the idea - we don't know which range should we
choose - from 0 to 2*pi or from -pi to pi or smth... But this bug can
be easily removed. If you still need a hint, email me.
Re: Thank you! I get AC.
Послано Happy New Year! Russia. 2 янв 2002 00:48
I don't know what you mean :|
Послано Miguel Angel 3 янв 2002 12:18
Could you explain with more detailed what's wrong with the test case
you print??
Thanks for all :)
Re: I don't know what you mean :|
Послано Happy New Year! Russia. 3 янв 2002 17:09
If you draw picture for my answer you'll see what's wrong:
     *
     |     | *----|--*
 \   |
  \  |
   \ |
    \|
     *
Re: Why I get WA? Pelase, help me!!!!!!!
Послано Yuan 15 мар 2002 11:26
what about this case

0 0
3
-1 -8 1
-2 -7 2
8 1 3