ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1030. Титаник

I got "Crash (ACCESS_VIOLATION)". What does it mean?
Послано XiaoTian 18 янв 2003 19:42
{No.1030 Titanic.}
Const
     pi=3.1415926535897932384626433832795;
Var
     Char1,NS1,EW1,NS2,EW2:Char;
     A1,B1,C1,D1,E1,F1,A2,B2,C2,D2,E2,F2:Integer;
     SqrD,Alpha,L,X1,Y1,Z1,X2,Y2,Z2:Real;
Function ReadNum:Integer;
Var
     Str1:String;
     Code,Num:Integer;
     Char1:Char;
Begin
     Str1:='##';
     Read(Str1[1]); Read(Str1[2]);
     Read(Char1);
     If Char1 In ['0'..'9'] Then
          Str1:=Str1+Char1;
     Val(Str1,Num,Code);
     ReadNum:=Num;
End;
Procedure Cal(Theta1,Theta2:Real;NS,EW:Char;Var X,Y,Z:Real);
Begin
     If NS='N' Then
          Z:=Sin(Theta1)
     Else Z:=-Sin(Theta1);
     X:=Cos(Theta2)*Cos(Theta1);
     If EW='E' Then
          Y:=Sin(Theta2)*Cos(Theta1)
     Else Y:=-Sin(Theta2)*Cos(Theta1);
End;
Begin
     ReadLn;
     ReadLn;
     ReadLn;

     A1:=ReadNum;
     B1:=ReadNum;
     C1:=ReadNum;
     Read(Char1);
     Read(NS1);
     ReadLn;

     Read(Char1); Read(Char1); Read(Char1); Read(Char1);
     D1:=ReadNum;
     E1:=ReadNum;
     F1:=ReadNum;
     Read(Char1);
     Read(EW1);
     ReadLn;

     ReadLn;

     A2:=ReadNum;
     B2:=ReadNum;
     C2:=ReadNum;
     Read(Char1);
     Read(NS2);
     ReadLn;

     Read(Char1); Read(Char1); Read(Char1); Read(Char1);
     D2:=ReadNum;
     E2:=ReadNum;
     F2:=ReadNum;
     Read(Char1);
     Read(EW2);
     ReadLn;
     ReadLn;

     Cal((((C1/60)+B1)/60+A1)/180*pi,(((F1/60)
+E1)/60+D1)/180*pi,NS1,EW1,X1,Y1,Z1);
     Cal((((C2/60)+B2)/60+A2)/180*pi,(((F2/60)
+E2)/60+D2)/180*pi,NS2,EW2,X2,Y2,Z2);

     If (Abs(X1+X2)<1E-7) And (Abs(Y1+Y2)<1E-7) And (Abs(Z1+Z2)<1E-7)
Then
          Alpha:=pi
     Else Begin
          SqrD:=Sqr(X1-X2)+Sqr(Y1-Y2)+Sqr(Z1-Z2);
          Alpha:=Arctan(Sqrt(SqrD)/2/Sqrt(1-SqrD/4))*2;
     End;
     L:=Alpha*6875/2;
     WriteLn('The distance to the iceberg: ',L:0:2,' miles.');
     If 100-L>1E-7 Then
          WriteLn('DANGER!');
End.
Re: I got "Crash (ACCESS_VIOLATION)". What does it mean?
Послано Илья Гофман (Ilya Gofman) 18 янв 2003 19:46
This possibly mean that you try to access the element of the array
with the number that doesn't exist or something like that.
  Good Luck!!!
I correct it, but now WA. Why?
Послано XiaoTian 19 янв 2003 09:08
{No.1030 Titanic.}
{$N+}
Const
     pi=3.1415926535897932384626433832795;
Var
     Char1,NS1,EW1,NS2,EW2:Char;
     A1,B1,C1,D1,E1,F1,A2,B2,C2,D2,E2,F2:Integer;
     SqrD,Alpha,L,X1,Y1,Z1,X2,Y2,Z2:Double;
Function ReadNum:Integer;
Var
     Str1:String;
     Code,Num:Integer;
     Char1:Char;
Begin
     Str1:='';
     Read(Char1); Str1:=Str1+Char1;
     Read(Char1);
     If Char1 In ['0'..'9'] Then
     Begin
          Str1:=Str1+Char1;
          Read(Char1);
          If Char1 In ['0'..'9'] Then
               Str1:=Str1+Char1;
     End;
     Val(Str1,Num,Code);
     ReadNum:=Num;
End;
Procedure Cal(Theta1,Theta2:Double;NS,EW:Char;Var X,Y,Z:Double);
Begin
     If NS='N' Then
          Z:=Sin(Theta1)
     Else Z:=-Sin(Theta1);
     X:=Cos(Theta2)*Cos(Theta1);
     If EW='E' Then
          Y:=Sin(Theta2)*Cos(Theta1)
     Else Y:=-Sin(Theta2)*Cos(Theta1);
End;
Begin
     ReadLn;
     ReadLn;
     ReadLn;

     A1:=ReadNum;
     B1:=ReadNum;
     C1:=ReadNum;
     Read(Char1);
     Read(NS1);
     ReadLn;

     Read(Char1); Read(Char1); Read(Char1); Read(Char1);
     D1:=ReadNum;
     E1:=ReadNum;
     F1:=ReadNum;
     Read(Char1);
     Read(EW1);
     ReadLn;

     ReadLn;

     A2:=ReadNum;
     B2:=ReadNum;
     C2:=ReadNum;
     Read(Char1);
     Read(NS2);
     ReadLn;

     Read(Char1); Read(Char1); Read(Char1); Read(Char1);
     D2:=ReadNum;
     E2:=ReadNum;
     F2:=ReadNum;
     Read(Char1);
     Read(EW2);
     ReadLn;
     ReadLn;

     Cal((((C1/60)+B1)/60+A1)/180*pi,(((F1/60)
+E1)/60+D1)/180*pi,NS1,EW1,X1,Y1,Z1);
     Cal((((C2/60)+B2)/60+A2)/180*pi,(((F2/60)
+E2)/60+D2)/180*pi,NS2,EW2,X2,Y2,Z2);

     If (Abs(X1+X2)<1E-10) And (Abs(Y1+Y2)<1E-10) And (Abs(Z1+Z2)<1E-
10) Then
          Alpha:=pi
     Else Begin
          SqrD:=Sqr(X1-X2)+Sqr(Y1-Y2)+Sqr(Z1-Z2);
          Alpha:=Arctan(Sqrt(SqrD)/2/Sqrt(1-SqrD/4))*2;
     End;
     L:=Alpha*6875/2;
     WriteLn('The distance to the iceberg: ',L:0:2,' miles.');
     If 100-L>0 Then
          WriteLn('DANGER!');
End.
You see, in your program such case is possible: when you write distance 100.00, but write DANGER! Round error (-)
Послано Dmitry 'Diman_YES' Kovalioff 19 янв 2003 12:01
Error corrected, but I still got WA.
Послано XiaoTian 19 янв 2003 14:31
{No.1030 Titanic.}
{$N+}
Const
     pi=3.1415926535897932384626433832795;
Var
     Char1,NS1,EW1,NS2,EW2:Char;
     A1,B1,C1,D1,E1,F1,A2,B2,C2,D2,E2,F2:Integer;
     SqrD,Alpha,L,X1,Y1,Z1,X2,Y2,Z2:Double;
Function ReadNum:Integer;
Var
     Str1:String;
     Code,Num:Integer;
     Char1:Char;
Begin
     Str1:='';
     Read(Char1); Str1:=Str1+Char1;
     Read(Char1);
     If Char1 In ['0'..'9'] Then
     Begin
          Str1:=Str1+Char1;
          Read(Char1);
          If Char1 In ['0'..'9'] Then
               Str1:=Str1+Char1;
     End;
     Val(Str1,Num,Code);
     ReadNum:=Num;
End;
Procedure Cal(Theta1,Theta2:Double;NS,EW:Char;Var X,Y,Z:Double);
Begin
     If NS='N' Then
          Z:=Sin(Theta1)
     Else Z:=-Sin(Theta1);
     X:=Cos(Theta2)*Cos(Theta1);
     If EW='E' Then
          Y:=Sin(Theta2)*Cos(Theta1)
     Else Y:=-Sin(Theta2)*Cos(Theta1);
End;
Begin
     ReadLn;
     ReadLn;
     ReadLn;

     A1:=ReadNum;
     B1:=ReadNum;
     C1:=ReadNum;
     Read(Char1);
     Read(NS1);
     ReadLn;

     Read(Char1); Read(Char1); Read(Char1); Read(Char1);
     D1:=ReadNum;
     E1:=ReadNum;
     F1:=ReadNum;
     Read(Char1);
     Read(EW1);
     ReadLn;

     ReadLn;

     A2:=ReadNum;
     B2:=ReadNum;
     C2:=ReadNum;
     Read(Char1);
     Read(NS2);
     ReadLn;

     Read(Char1); Read(Char1); Read(Char1); Read(Char1);
     D2:=ReadNum;
     E2:=ReadNum;
     F2:=ReadNum;
     Read(Char1);
     Read(EW2);
     ReadLn;
     ReadLn;

     Cal((((C1/60)+B1)/60+A1)/180*pi,(((F1/60)
+E1)/60+D1)/180*pi,NS1,EW1,X1,Y1,Z1);
     Cal((((C2/60)+B2)/60+A2)/180*pi,(((F2/60)
+E2)/60+D2)/180*pi,NS2,EW2,X2,Y2,Z2);

     If (Abs(X1+X2)<1E-10) And (Abs(Y1+Y2)<1E-10) And (Abs(Z1+Z2)<1E-
10) Then
          Alpha:=pi
     Else Begin
          SqrD:=Sqr(X1-X2)+Sqr(Y1-Y2)+Sqr(Z1-Z2);
          Alpha:=Arctan(Sqrt(SqrD)/2/Sqrt(1-SqrD/4))*2;
     End;
     L:=Alpha*6875/2;
     Write('The distance to the iceberg: ');
     Write(L:0:2);
     WriteLn(' miles.');
     If Round(L*100)<10000 Then
          WriteLn('DANGER!');
End.
Maybe such case is possible: many messages in one test (-)
Послано Dmitry 'Diman_YES' Kovalioff 19 янв 2003 21:24
All the tests are here.I got them from Zhu Zheyuan.
Послано Lin 21 янв 2003 10:51
Message #488.
Received at 18:15:23.
Current ship's coordinates are
45^00'00" SL
and 45^00'00" WL.
An iceberg was noticed at
45^00'00" NL
and 45^00'00" WL.
===
Message #488.
Received at 18:15:23.
Current ship's coordinates are
41^46'00" NL
and 50^14'00" WL.
An iceberg was noticed at
41^14'11" NL
and 51^09'00" WL.
===
Message #488.
Received at 18:15:23.
Current ship's coordinates are
45^00'00" SL
and 45^00'00" WL.
An iceberg was noticed at
45^00'00" NL
and 135^00'00" EL.
===
Message #488.
Received at 18:15:23.
Current ship's coordinates are
90^00'00" NL
and 50^14'00" WL.
An iceberg was noticed at
90^00'00" SL
and 151^09'00" WL.
===
Message #488.
Received at 18:15:23.
Current ship's coordinates are
0^00'00" NL
and 50^00'00" WL.
An iceberg was noticed at
0^00'00" SL
and 130^00'00" EL.
===
Message #488.
Received at 18:15:23.
Current ship's coordinates are
40^00'00" NL
and 1^00'00" WL.
An iceberg was noticed at
40^00'00" NL
and 1^00'00" EL.
===
Message #488.
Received at 18:15:23.
Current ship's coordinates are
40^09'18" NL
and 1^00'01" WL.
An iceberg was noticed at
40^50'11" NL
and 1^00'00" EL.
===
Message #488.
Received at 18:15:23.
Current ship's coordinates are
40^09'19" NL
and 1^00'01" WL.
An iceberg was noticed at
40^50'12" NL
and 1^00'00" EL.
===
Is my answer right?
Послано XiaoTian 22 янв 2003 14:22
The distance to the iceberg: 5399.61 miles.
The distance to the iceberg: 52.04 miles.
DANGER!
The distance to the iceberg: 7199.48 miles.
The distance to the iceberg: 10799.22 miles.
The distance to the iceberg: 4799.66 miles.
The distance to the iceberg: 91.92 miles.
DANGER!
The distance to the iceberg: 100.00 miles.
The distance to the iceberg: 99.99 miles.
DANGER!
Re: Is my answer right?
Послано Sergei Pupyrev (USU) 10 фев 2003 19:58
> The distance to the iceberg: 5399.61 miles.
> The distance to the iceberg: 52.04 miles.
> DANGER!
> The distance to the iceberg: 7199.48 miles.
> The distance to the iceberg: 10799.22 miles.
> The distance to the iceberg: 4799.66 miles.
> The distance to the iceberg: 91.92 miles.
> DANGER!
> The distance to the iceberg: 100.00 miles.
> The distance to the iceberg: 99.99 miles.
> DANGER!
>
Sorry
Послано Sergei Pupyrev (USU) 10 фев 2003 19:59
> The distance to the iceberg: 5399.61 miles.
> The distance to the iceberg: 52.04 miles.
> DANGER!
> The distance to the iceberg: 7199.48 miles.
> The distance to the iceberg: 10799.22 miles.
> The distance to the iceberg: 4799.66 miles.
> The distance to the iceberg: 91.92 miles.
> DANGER!
> The distance to the iceberg: 100.00 miles.
> The distance to the iceberg: 99.99 miles.
> DANGER!
>
Look carefully at test :
Message #488.
Received at 18:15:23.
Current ship's coordinates are
45^00'00" SL
and 45^00'00" WL.
An iceberg was noticed at
45^00'00" NL
and 135^00'00" EL.
===
My answer is 10799.22
Re: Sorry
Послано alp 21 сен 2013 23:55
AC program gives answers
The distance to the iceberg: 5399.61 miles.
The distance to the iceberg: 52.04 miles.
DANGER!
The distance to the iceberg: 10799.22 miles.
The distance to the iceberg: 10799.22 miles.
The distance to the iceberg: 10799.22 miles.
The distance to the iceberg: 91.92 miles.
DANGER!
The distance to the iceberg: 100.00 miles.
The distance to the iceberg: 99.99 miles.
DANGER!