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

Need help. Look over my code or give some tests please.
Posted by Akshin Salimov 12 Apr 2005 22:19
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
Posted by Виктор Крупко 12 Apr 2005 22:57
2 1 4 2
0 0 1
YOUR: -1.00???? 3.47
AC: 1.24 3.47
Re: SEE
Posted by SSS 13 Apr 2005 23:23
What do you think how it can be changed?
I think to change the decision is necessary.
Posted by Виктор Крупко 14 Apr 2005 02:52
:):):):):):):):):):):):):):):)+++++++++++++++++++++
Re: I think to change the decision is necessary.
Posted by SSS 15 Apr 2005 11:05
I'm not talking about decision, decision is right. I said that how code can be changed to get AC?
Here is modified one:
Posted by Akshin Salimov 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.
Re: Here is modified one:
Posted by SSS 15 Apr 2005 20:19
Seems correct but gets WA#4
Re: Here is modified one:
Posted by Виктор Крупко 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
Re: Here is modified one:
Posted by einstein17 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:
Posted by Виктор Крупко 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.
Re: Here is modified one:
Posted by Snetch 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);
Try this:
Posted by ErOPb|4[USU] 1 Aug 2008 10:47
-5 0 5 0 0 5 100
Correct answer is 0.00 0.00