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 1348. Goat in the Garden 2

Please help me, look over my code, I'll be thankfull to anyone who will find mistake in my code, or give me some tests.

var
  h,s,aa,bb:real;
  a:array[1..3,1..2] of integer;
  i,l:integer;


procedure readdata;
begin
  readln(a[1,1],a[1,2],a[2,1],a[2,2]);
  readln(a[3,1],a[3,2],l);
end;

procedure writedata;
begin
  writeln(aa:0:2);
  writeln(bb:0:2);
end;

function d(x1,y1,x2,y2:integer):real;
begin
  d:=sqrt(sqr(x1-x2)+sqr(y1-y2));
end;

procedure square;
var
  p,a1,a2,a3:real;
begin
  a1:=d(a[1,1],a[1,2],a[2,1],a[2,2]);
  a2:=d(a[3,1],a[3,2],a[2,1],a[2,2]);
  a3:=d(a[1,1],a[1,2],a[3,1],a[3,2]);
  p:=(a1+a2+a3)/2;
  s:=sqrt(p*(p-a1)*(p-a2)*(p-a2));
end;

begin
  readdata;
  square;

  h:=d(a[1,1],a[1,2],a[2,1],a[2,2]);

  aa:=s/(0.5*h);
  if d(a[1,1],a[1,2],a[3,1],a[3,2])<aa
  then aa:=d(a[1,1],a[1,2],a[3,1],a[3,2]);
  if d(a[2,1],a[2,2],a[3,1],a[3,2])<aa
  then aa:=d(a[2,1],a[2,2],a[3,1],a[3,2]);

  bb:=d(a[3,1],a[3,2],a[2,1],a[2,2]);
  if d(a[3,1],a[3,2],a[1,1],a[1,2])>bb then
  bb:=d(a[3,1],a[3,2],a[1,1],a[1,2]);
  if (s/(0.5*h))>bb then bb:=(s/(0.5*h));

  aa:=aa-l;
  bb:=bb-l;
  writedata;
end.
Виктор Крупко SEE [10] // Problem 1348. Goat in the Garden 2 12 Apr 2005 22:57
2 1 4 2
0 0 1
YOUR: -1.00???? 3.47
AC: 1.24 3.47
SSS Re: SEE [2] // Problem 1348. Goat in the Garden 2 13 Apr 2005 23:23
What do you think how it can be changed?
Виктор Крупко I think to change the decision is necessary. [1] // Problem 1348. Goat in the Garden 2 14 Apr 2005 02:52
:):):):):):):):):):):):):):):)+++++++++++++++++++++
I'm not talking about decision, decision is right. I said that how code can be changed to get AC?
Akshin Salimov Here is modified one: [6] // Problem 1348. Goat in the Garden 2 15 Apr 2005 20:15
I modified my code, it gives correct answer for your test but i still get this ****** WA#4 !!!

Here is code

var
  a1,a2,a3,h,s,aa,bb:real;
  a:array[1..3,1..2] of integer;
  i,l:integer;


procedure readdata;
begin
  reset(input);}
  readln(a[1,1],a[1,2],a[2,1],a[2,2]);
  readln(a[3,1],a[3,2],l);
end;

procedure writedata;
begin
  writeln(aa:0:2);
  writeln(bb:0:2);
end;

function d(x1,y1,x2,y2:integer):real;
begin
  d:=sqrt(sqr(x1-x2)+sqr(y1-y2));
end;

procedure square;
var
  p:real;
begin
  a1:=d(a[1,1],a[1,2],a[2,1],a[2,2]);
  a2:=d(a[3,1],a[3,2],a[2,1],a[2,2]);
  a3:=d(a[1,1],a[1,2],a[3,1],a[3,2]);
  p:=(a1+a2+a3)/2;
  s:=sqrt(p*(p-a1)*(p-a2)*(p-a2));
end;

begin
  readdata;
  square;

  if (a1*a1+a2*a2<a3*a3) or (a2*a2+a3*a3<a1*a1) or (a1*a1+a3*a3<a2*a2) then
  begin
    aa:=d(a[1,1],a[1,2],a[3,1],a[3,2]);
    if d(a[2,1],a[2,2],a[3,1],a[3,2])<aa
    then aa:=d(a[2,1],a[2,2],a[3,1],a[3,2]);
  end  else
  begin
    h:=d(a[1,1],a[1,2],a[2,1],a[2,2]);
    aa:=s/(0.5*h);
  end;

  bb:=d(a[3,1],a[3,2],a[2,1],a[2,2]);
  if d(a[3,1],a[3,2],a[1,1],a[1,2])>bb then
  bb:=d(a[3,1],a[3,2],a[1,1],a[1,2]);

  aa:=aa-l;
  bb:=bb-l;
  writedata;
end.
SSS Re: Here is modified one: [3] // Problem 1348. Goat in the Garden 2 15 Apr 2005 20:19
Seems correct but gets WA#4
Виктор Крупко Re: Here is modified one: [2] // Problem 1348. Goat in the Garden 2 16 Apr 2005 00:31
aa always >=0
bb always >=0
Before an input in procedure write make terms that was not aa <0 and bb <0
einstein17 Re: Here is modified one: [1] // Problem 1348. Goat in the Garden 2 16 Apr 2005 20:05
Maybe I'm Error,But,What mistake you think?I can not to found any mistake
Виктор Крупко Re: Here is modified one: // Problem 1348. Goat in the Garden 2 16 Apr 2005 22:20
At a conclusion check up that aa and bb were not negative,
If they will be negative appropriate him 0.
Snetch Re: Here is modified one: [1] // Problem 1348. Goat in the Garden 2 20 Dec 2007 04:16
Spaces and line feeds can follow each other in any order, so you need only to Read([1,1],a[1,2],a[2,1],a[2,2],a[3,1],a[3,2],l);
ErOPb|4[USU] Try this: // Problem 1348. Goat in the Garden 2 1 Aug 2008 10:47
-5 0 5 0 0 5 100
Correct answer is 0.00 0.00