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

Common Board

1030 Titanic to all that got accept.
Posted by Jivko Ganev 26 Oct 2000 23:59
I keep getting W.A. in 1030.I think my program is ok and i
get right result in the sample.I am not sure what " Also
you can be sure that lines in the input file break exactly
as it is shown in the input samples" means. Does it mean
that the lines are EXACTLY the same or the lines are the
same but there may be extra spaces??To solve 1030 I first
find the x, y, z of both the ship and the iceberg in 0xyz
where 0 is the centre of the sphere. Then I find the
distance between the ship and the iceberg.I use the
distance to find the cosine of the angle in the triangle
that consists of(r, r, the distance).I do this with cosine
therem and (i find the cosine of the angle agains the side
that is = distance).After that i find the angle with arccos
and use the equation F = r * angle where F is the answer.
I don't know if F is 99.999999 then should I write 100.00
or 99.99 and should I use 99.99 to check if the distance is
< 100 or 100.00 or 99.999999???

Here are some inputs and what I get with them:

90^00'00" NL
and 00^00'00" WL.
An iceberg was noticed at
90^00'00" SL
and 00^00'00" WL.
The distance to the iceberg: 10799.22 miles.

45^22'30" NL
and 75^00'14" WL.
An iceberg was noticed at
33^11'14" SL
and 130^19'00" WL.
The distance to the iceberg: 5588.83 miles.

45^22'30" NL
and 74^00'19" WL.
An iceberg was noticed at
13^11'14" SL
and 33^19'00" EL.
The distance to the iceberg: 6687.68 miles.
Re: 1030 Titanic to all that got accept.
Posted by Petko Minkov 27 Oct 2000 02:06
> I keep getting W.A. in 1030.I think my program is ok and
i
> get right result in the sample.I am not sure what " Also
> you can be sure that lines in the input file break
exactly
> as it is shown in the input samples" means. Does it mean
> that the lines are EXACTLY the same or the lines are the
> same but there may be extra spaces??To solve 1030 I first
> find the x, y, z of both the ship and the iceberg in 0xyz
> where 0 is the centre of the sphere. Then I find the
> distance between the ship and the iceberg.I use the
> distance to find the cosine of the angle in the triangle
> that consists of(r, r, the distance).I do this with
cosine
> therem and (i find the cosine of the angle agains the
side
> that is = distance).After that i find the angle with
arccos
> and use the equation F = r * angle where F is the answer.
> I don't know if F is 99.999999 then should I write 100.00
> or 99.99 and should I use 99.99 to check if the distance
is
> < 100 or 100.00 or 99.999999???
>
> Here are some inputs and what I get with them:
>
> 90^00'00" NL
> and 00^00'00" WL.
> An iceberg was noticed at
> 90^00'00" SL
> and 00^00'00" WL.
> The distance to the iceberg: 10799.22 miles.
>
> 45^22'30" NL
> and 75^00'14" WL.
> An iceberg was noticed at
> 33^11'14" SL
> and 130^19'00" WL.
> The distance to the iceberg: 5588.83 miles.
>
> 45^22'30" NL
> and 74^00'19" WL.
> An iceberg was noticed at
> 13^11'14" SL
> and 33^19'00" EL.
> The distance to the iceberg: 6687.68 miles.
>
>

  Tochnost 99.995 shte bachka.
ChСp, bµi nµy th« lѕm, bдn nga ®уng lµ quё ®ёng mµ, hхm
Posted by Dinh Quang Hiep (mg9h@yahoo.com) 28 Oct 2000 10:34
Re: 1030 Titanic to all that got accept.
Posted by Deian Lambov 30 Oct 2000 22:16
> I keep getting W.A. in 1030.I think my program is ok and
i
> get right result in the sample.I am not sure what " Also
> you can be sure that lines in the input file break
exactly
> as it is shown in the input samples" means. Does it mean
> that the lines are EXACTLY the same or the lines are the
> same but there may be extra spaces??To solve 1030 I first
> find the x, y, z of both the ship and the iceberg in 0xyz
> where 0 is the centre of the sphere. Then I find the
> distance between the ship and the iceberg.I use the
> distance to find the cosine of the angle in the triangle
> that consists of(r, r, the distance).I do this with
cosine
> therem and (i find the cosine of the angle agains the
side
> that is = distance).After that i find the angle with
arccos
> and use the equation F = r * angle where F is the answer.
> I don't know if F is 99.999999 then should I write 100.00
> or 99.99 and should I use 99.99 to check if the distance
is
> < 100 or 100.00 or 99.999999???
>
> Here are some inputs and what I get with them:
>
> 90^00'00" NL
> and 00^00'00" WL.
> An iceberg was noticed at
> 90^00'00" SL
> and 00^00'00" WL.
> The distance to the iceberg: 10799.22 miles.
>
> 45^22'30" NL
> and 75^00'14" WL.
> An iceberg was noticed at
> 33^11'14" SL
> and 130^19'00" WL.
> The distance to the iceberg: 5588.83 miles.
>
> 45^22'30" NL
> and 74^00'19" WL.
> An iceberg was noticed at
> 13^11'14" SL
> and 33^19'00" EL.
> The distance to the iceberg: 6687.68 miles.
>
>
I use the same method as you and I get the same answers to
these 3 inputs! And I get WA from the online judge!

I am sure, my solution is rigth.
Are there several test cases in the input?
Does the compiler watch for Range Check Errors?
Re: 1030 Titanic to all that got accept.(I finally got it)
Posted by Jivko Ganev 4 Nov 2000 02:28
All the time I had right solution, with problem in the
input.I didn't expect that there would be coordinates like
3^3'3".Also I would like to mention that in my opinion
problems involving comparison on derived floating point
numbers are very bad.The input in this problem is very ugly
and I think that parsing the input should be trivial for
all problems,except for those that are parsing related(D++,
Spell checker etc).
Re: but the input parsing IS trivial!
Posted by Ilya Semenov (NSU) 5 Nov 2000 16:50
> and I think that parsing the input should be trivial for
> all problems,except for those that are parsing related
> (D++, Spell checker etc).

scanf( "Message #%d.\n"     "Received at %d:%d:%d.\n"     "Current ship's coordinates are\n"     "%d^%d'%d\" %cL\n"     "and %d^%d'%d\" %cL.\n"     "An iceberg was noticed at\n"     "%d^%d'%d\" %cL\n"     "and %d^%d'%d\" %cL.",
    &msgid, &time, &time, &time,
    &ship_h1, &ship_m1, &ship_s1, &ship_d1, &ship_h2,
&ship_m2, &ship_s2, &ship_d2,
    &ice_h1, &ice_m1, &ice_s1, &ice_d1, &ice_h2,
&ice_m2, &ice_s2, &ice_d2 );
I use pascal (and didn't expect problems with the input):
Posted by Jivko Ganev 5 Nov 2000 20:35
const
  infile = '';
  outfile = '';
  nums : set of char = ['0'..'9'];
  de = 6875;
  eps = 0.005;

var
  x1, x2, y1, y2, z1, z2 : word;
  p1, p2, q1, q2 : extended;
  re, dist : extended;


procedure parse(var a : extended; s : string);
var i : longint;
  j : byte;
  t : extended;
  code : integer;
  s1 : string;
begin
  i := 1;
  while NOT (s[i] in nums) do inc(i);
  s1 := copy(s, i, pos('^', s) - i);
  val(s1, t, code);
  a := t;
  s1 := copy(s, pos('^', s) + 1, pos('''', s) - pos('^',
s) - 1);
  val(s1, t, code);
  a := a + t / 60;
  s1 := copy(s, pos('''', s) + 1, pos('"', s) - pos('''',
s) - 1);
  val(s1, t, code);
  a := a + t / 3600;
  a := a * pi / 180;
end;

procedure indata;
var f : text;
  s, s1 : string;
  t : extended;
  code : integer;
begin
  assign(f, infile);
  reset(f);
  readln(f);
  readln(f);
  readln(f);
  readln(f, s);
  parse(p1, s);
  if pos('NL', s) <> 0 then p1 := - p1;
  readln(f, s);
  parse(p2, s);
  if pos('EL', s) <> 0 then p2 := - p2;
  readln(f);
  readln(f, s);
  parse(q1, s);
  if pos('NL', s) <> 0 then q1 := - q1;
  readln(f, s);
  parse(q2, s);
  if pos('EL', s) <> 0 then q2 := - q2;
  close(f);
end;