ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1130. Nikifor's Walk

I wonder, why I get WA? Please, help me!
Posted by Nazarov Denis (nsc2001@rambler.ru) 27 Jan 2002 14:24
My program:

Program t1130;{$N+}

Const MaxN=10000;

Var  T         :array[1..MaxN,1..3]of longint;
     N,i,j     :longint;
     L         :extended;
     Ci,Cj     :extended;
     ex        :boolean;

begin
 FillChar(T,SizeOf(T),0);
 Ci:=0;
 Cj:=0;
 Read(N,L);
 for i:=1 to N do begin
   Read(T[i,1],T[i,2]);
   T[i,3]:=1;
   Ci:=Ci+T[i,1];
   Cj:=Cj+T[i,2];
  end;
 Repeat
  ex:=true;
  for i:=1 to N do
   if T[i,3]=1 then
    if Sqr(Ci-2*T[i,1])+Sqr(Cj-2*T[i,2])<Ci*Ci+Cj*Cj then begin
     T[i,3]:=-1;
     Ci:=Ci-2*T[i,1];
     Cj:=Cj-2*T[i,2];
     ex:=false;
    end
   else
    if Sqr(Ci+2*T[i,1])+Sqr(Cj+2*T[i,2])<Ci*Ci+Cj*Cj then begin
     T[i,3]:=1;
     Ci:=Ci+2*T[i,1];
     Cj:=Cj+2*T[i,2];
     ex:=false;
    end;
 if (ex)and(Ci*Ci+Cj*Cj>2*L*L) then begin
   T[N,3]:=-1*T[N,3];
   Ci:=Ci+2*T[N,3]*T[N,1];
   Cj:=Cj+2*T[N,3]*T[N,2];
   ex:=false;
  end;
 Until ex;
   Writeln('YES');
   for i:=1 to N do
    if T[i,3]=1 then Write('+') else Write('-');
   Writeln;
end.
My program is similar to yours , but I 've got accept
Posted by XueMao 29 Jul 2002 11:58
{$n+}
Program Walk;

Var i,j,k,m,n,bj:longint;
    x,y,z:double;
    a:array[1..10001,1..2] of integer;
    e:array[1..10001] of shortint;

Begin
  fillchar(a,sizeof(a),0);
  fillchar(e,sizeof(e),0);
  read(n);
  read(z);
  x:=0;
  y:=0;
  for i:=1 to n do
  begin
    e[i]:=1;
    read(a[i,1],a[i,2]);
    x:=x+a[i,1];
    y:=y+a[i,2];
  end;
  while x*x+y*y-2*z*z>1e-14 do
  begin
    for i:=1 to n do
    if sqrt(x*x+y*y)-Sqrt(sqr(x-2*a[i,1]*e[i])+sqr(y-2*a[i,2]*e[i]))
>1e-14 then
    begin
      x:=x-2*a[i,1]*e[i];
      y:=y-2*a[i,2]*e[i];
      e[i]:=-e[i];
      if 2*z*z-x*x-y*y>1e-14 then break;
    end;
  end;
  writeln('YES');
  for i:=1 to n do
  if e[i]=-1 then write('-')
  else write('+');
  writeln;
End.
Re: My program is similar to yours , but I 've got accept
Posted by Iqrom_BeK 28 Aug 2007 19:47
Dont believe this programm it gets TLE on test12