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 1215. Exactness of Projectile Hit

Help please... WA4...
Posted by Neo Nomaly 16 Jan 2006 16:52
{$APPTYPE CONSOLE}
{$n+}
uses
  SysUtils;

type
  tpoint=record
           x,y:{longint} extended;
         end;
const
  maxn=200;
var
  a:array[1..maxn] of tpoint;
  n:longint;
  min:extended;
  f:tpoint;
procedure init;
var
  i:longint;
begin
  assign(input,'input.txt');
  reset(input);
  assign(output,'output.txt');
  rewrite(output);
  readln(f.x,f.y,n);
  for i:=1 to n do
    readln(a[i].x,a[i].y);
  inc(n);
  a[n+1].x:=a[1].x;
  a[n+1].y:=a[1].y;
  min:=maxlongint;
end;
function scalmul(p1,p2,p3,p4:tpoint):extended;
begin
  scalmul:=(p2.x-p1.x)*(p4.x-p3.x)+(p2.y-p1.y)*(p4.y-p3.y);
end;
function rast(p1,p2:tpoint):extended;
begin
  rast:=sqrt(sqr(p2.x-p1.x)+sqr(p2.y-p1.y));
end;
function vecmul(p1,p2,p3,p4:tpoint):extended;
begin
  vecmul:=(p2.x-p1.x)*(p4.y-p3.y)-(p2.y-p1.y)*(p4.x-p3.x);
end;
function prov:boolean;
var
  i,j:longint;
  b:boolean;
begin
  b:=true;
  for i:=1 to n-1 do
    if vecmul(a[i],f,a[i],a[i+1])>=0 then begin
      if b then b:=false;
    end;
  prov:=b;
end;
procedure solve;
var
  i,j,im,l,r:longint;
  h:extended;
begin
  if prov then begin
    writeln(0.0:0:3);
    halt;
  end;
  dec(n);
  for i:=1 to n do
    if rast(f,a[i])<min then begin
       min:=rast(f,a[i]);
       im:=i;
    end;
  l:=i-1;
  r:=i+1;
  if l<1 then inc(l,n);
  if r>n then dec(r,n);
  if (scalmul(a[l],f,a[l],a[im])>0) and (scalmul(a[im],f,a[im],a[l])>0) then begin
    h:=vecmul(f,a[im],f,a[l])/rast(a[im],a[l]);
    if min>h then min:=h;
  end;
  if (scalmul(a[r],f,a[r],a[im])>0) and (scalmul(a[im],f,a[im],a[r])>0) then begin
    h:=vecmul(f,a[im],f,a[r])/rast(a[im],a[r]);
    if min>h then min:=h;
  end;
end;
procedure done;
begin
  writeln(abs(min*2):0:3);
end;
begin
  init;
  solve;
  done;
end.
Re: Help please... WA4...
Posted by +FAMAS+ 18 Jan 2006 23:20
in 4 test answer 0.000 (100%)(так что думай)
Re: Help please... WA4...
Posted by Love SJC 19 Feb 2008 20:01
yeah
I have writtln 0 and I got WA at #4test
then i wrote 0.000 and got AC
Re: Help please... WA4...
Posted by Li Wang Ji 20 Feb 2008 18:59
I didn't understand where was the mistake in the code... if you have true code can you send me it on my e-mail, please?
my e-mail : liwang@mail.ru
I can send you any code if I have solved it. don't look to my account. just send me the number that you want. if I have it I will send you in return for this problem. thank you