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

help why i wa5
Posted by Edric Mao 2 Oct 2010 21:15
program ural;
var n,l,i,p,q:integer;
    x,y:array[1..2]of integer;
    a,b:integer;
    c,u:array[1..10000]of boolean;
begin
  readln(n,l);
  if n=1 then
    begin
      writeln('YES');
      writeln('+');
      halt;
    end;
  l:=l*l;
  readln(x[1],y[1]);
  readln(x[2],y[2]);
  c[1]:=true;
  c[2]:=true;
  for i:=3 to n do
    begin
      readln(a,b);
      p:=x[1]+a;
      q:=y[1]+b;
      if sqr(p)+sqr(q)<=l then
        begin
          x[1]:=p;
          y[1]:=q;
          u[i]:=true;
          c[i]:=true;
          continue;
        end;
      p:=x[1]-a;
      q:=y[1]-b;
      if sqr(p)+sqr(q)<=l then
        begin
          x[1]:=p;
          y[1]:=q;
          u[i]:=true;
          continue;
        end;
      p:=x[2]+a;
      q:=y[2]+b;
      if sqr(p)+sqr(q)<=l then
        begin
          x[2]:=p;
          y[2]:=q;
          c[i]:=true;
          continue;
        end;
      p:=x[2]-a;
      q:=y[2]-b;
      if sqr(p)+sqr(q)<=l then
        begin
          x[2]:=p;
          y[2]:=q;
          continue;
        end;
    end;
  if sqr(x[1]+x[2])+sqr(y[1]+y[2])>2*l then
    c[2]:=not c[2];
  writeln('YES');
  write('+');
  if c[2] then
    write('+')
  else
    write('-');
  for i:=3 to n do
    begin
      if u[i] then
        begin
          if c[i] then
            write('+')
          else
            write('-');
        end
      else
        begin
          if c[i]=false then
            c[i]:=not c[2];
          if c[i] then
            write('+')
          else
            write('-');
        end;
    end;
end.
Re: help why i wa5
Posted by Lucian Ilea 13 Dec 2010 20:57
try this test
3 10
10 0
0 10
5 5