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

Обсуждение задачи 1074. Очень короткая задача

Please give me the test on which my program is WRONG! HELP ME! (Problem 1074)
Послано Reshetnikov Eugeny 11 янв 2002 15:34
This is my program! Please Test her!

Program n1074;
  Var
    n,i,j,e,point,left,right,q:byte;
    znak:char;
    a:array [0..250] of string[255];
    b:array [0..250] of byte;
    c:array [0..250] of boolean;

Procedure Input;
  Begin
    n:=0;
    While a[n]<>'#' Do
      Begin
        Inc(n);
        ReadLn(a[n]);
        If a[n]<>'#' Then
          ReadLn(b[n]);
      End;
    Dec(n);
  End;

Procedure Solve;
  Begin
    For i:=1 to n Do
      Begin
        c[i]:=true;
        e:=0;
        point:=0;
        For j:=1 to Length(a[i]) Do
          Begin
            If ((a[i][j]='+') or (a[i][j]='-')) and (Not ((j=1) and
               (a[i][2]>='0') and (a[i][2]<='9'))) and (Not (((a[i][j-
1]='e')
               or (a[i][j-1]='E')) and (a[i][j+1]>='0') and (a[i][j+1]
<='9')))
            Then
              Begin
                c[i]:=false;
                Break;
              End;
            If ((a[i][j]='e') or (a[i][j]='E')) and (Not ((a[i][j-1]
>='0') and
               (a[i][j-1]<='9') and (a[i][j+1]>='0') and (a[i][j+1]
<='9')) and
               Not ((a[i][j-1]>='0') and (a[i][j-1]<='9') and ((a[i]
[j+1]='+')
               or (a[i][j+1]='-'))))
            Then
              Begin
                c[i]:=false;
                Break;
              End;
            If (a[i][j]='.') and (Not (((a[i][j-1]>='0') and (a[i][j-
1]<='9')
               or (j=1)) and (a[i][j+1]>='0') and (a[i][j+1]<='9')))
            Then
              Begin
                c[i]:=false;
                Break;
              End;
            If (a[i][j]='e') or (a[i][j]='E') Then
              Inc(e);
            If a[i][j]='.' Then
              Inc(point);
          End;
        If (e>1) or (point>1) Then
          c[i]:=false;
        If a[i][1]='+' Then
          Delete(a[i],1,1);
        For j:=1 to Length(a[i]) Do
          If (a[i][j]='.') and (j=1) Then
            Insert('0',a[i],j-1);
      End;
  End;

Procedure Solve2;
  Begin
    For i:=1 to n Do
      If c[i]=true Then
        Begin
          left:=0;
          right:=0;
          For j:=1 to Length(a[i]) Do
            If (a[i][j]='e') or (a[i][j]='E') Then
              Begin
                If a[i][j+1]='+' Then
                  Begin
                    For q:=(j+2) to Length(a[i]) Do
                      right:=right*10+(Ord(a[i][q])-Ord('0'));
                    Delete(a[i],j,Length(a[i])-j+1);
                    Break;
                  End
                Else
                  If (a[i][j+1]>='0') and (a[i][j+1]<='9') Then
                    Begin
                      For q:=(j+1) to Length(a[i]) Do
                        right:=right*10+(Ord(a[i][q])-Ord('0'));
                      Delete(a[i],j,Length(a[i])-j+1);
                      Break;
                    End
                  Else
                    If a[i][j+1]='-' Then
                      Begin
                        For q:=(j+2) to Length(a[i]) Do
                          left:=left*10+(Ord(a[i][q])-Ord('0'));
                        Delete(a[i],j,Length(a[i])-j+1);
                        Break;
                      End;
              End;
           If right<>0 Then
             Begin
               For j:=1 to Length(a[i]) Do
                 If a[i][j]='.' Then
                   Break;
               If j<>Length(a[i]) Then
                 Begin
                   While (j<>Length(a[i])) and (right>0) Do
                     Begin
                       a[i][j]:=a[i][j+1];
                       a[i][j+1]:='.';
                       Inc(j);
                       Dec(right);
                     End;
                   If j=Length(a[i]) Then
                     Dele
Here you are
Послано Mih 11 янв 2002 17:47
>     a:array [0..250] of string[255];
1:i don't know but there might be more than 250 strings in a file
2:some tests
--input---
abc
3
#
--your output---
c.000
----------
but it shold be "not a floating..." as you see.
your program always gives WA for "numbers" that have uncorrect
character on the first pos.
like this:
input:
aaa123bbb
0
#
your out:
123bbb

GL!
Re: Here you are
Послано Mih 11 янв 2002 17:50
in:
123abc
3
#
out:
123abc.000 - wa too.
Re: Here you are AGAIN
Послано Reshetnikov Eugeny 11 янв 2002 20:27
> in:
> 123abc
> 3
> #
> out:
> 123abc.000 - wa too.
Thank you! But my program got WA too!
This is MODERN program:
My prgram got WA on first test because the time is 0.001 or 0.01
don't remember! I Think What this is first test...

Program n1074;
  Var
    n,i,j,e,point,left,right,q:byte;
    znak:char;
    a:array [0..250] of string[255];
    b:array [0..250] of byte;
    c:array [0..250] of boolean;

Procedure Input;
  Begin
    n:=0;
    While a[n]<>'#' Do
      Begin
        Inc(n);
        ReadLn(a[n]);
        If a[n]<>'#' Then
          ReadLn(b[n]);
      End;
    Dec(n);
  End;

Procedure Solve;
  Begin
    For i:=1 to n Do
      Begin
        c[i]:=true;
        e:=0;
        point:=0;
        For j:=1 to Length(a[i]) Do
          Begin
            If ((a[i][j]='+') or (a[i][j]='-')) and (Not ((j=1) and
               (a[i][2]>='0') and (a[i][2]<='9'))) and (Not (((a[i][j-
1]='e')
               or (a[i][j-1]='E')) and (a[i][j+1]>='0') and (a[i][j+1]
<='9')))
            Then
              Begin
                c[i]:=false;
                Break;
              End;
            If ((a[i][j]='e') or (a[i][j]='E')) and (Not ((a[i][j-1]
>='0') and
               (a[i][j-1]<='9') and (a[i][j+1]>='0') and (a[i][j+1]
<='9')) and
               Not ((a[i][j-1]>='0') and (a[i][j-1]<='9') and ((a[i]
[j+1]='+')
               or (a[i][j+1]='-'))))
            Then
              Begin
                c[i]:=false;
                Break;
              End;
            If (a[i][j]='.') and (Not (((a[i][j-1]>='0') and (a[i][j-
1]<='9')
               or (j=1)) and (a[i][j+1]>='0') and (a[i][j+1]<='9')))
            Then
              Begin
                c[i]:=false;
                Break;
              End;
            If (a[i][j]='e') or (a[i][j]='E') Then
              Inc(e);
            If a[i][j]='.' Then
              Inc(point);
            If Not ((a[i][j]>='0') and (a[i][j]<='9')) and Not ((a[i]
[j]='e')
               or (a[i][j]='E')) and Not ((a[i][j]='+') or (a[i][j]='-
')) and
               Not (a[i][j]='.') and Not ((Ord(a[i][j])=10) or (Ord(a
[i][j])=13)
               or (Ord(a[i][j])=26)) Then
              Begin
                c[i]:=false;
                Break;
              End;
          End;
        If (e>1) or (point>1) Then
          c[i]:=false;
        If a[i][1]='+' Then
          Delete(a[i],1,1);
        For j:=1 to Length(a[i]) Do
          If (a[i][j]='.') and (j=1) Then
            Insert('0',a[i],j-1);
      End;
  End;

Procedure Solve2;
  Begin
    For i:=1 to n Do
      If c[i]=true Then
        Begin
          left:=0;
          right:=0;
          For j:=1 to Length(a[i]) Do
            If (a[i][j]='e') or (a[i][j]='E') Then
              Begin
                If a[i][j+1]='+' Then
                  Begin
                    For q:=(j+2) to Length(a[i]) Do
                      right:=right*10+(Ord(a[i][q])-Ord('0'));
                    Delete(a[i],j,Length(a[i])-j+1);
                    Break;
                  End
                Else
                  If (a[i][j+1]>='0') and (a[i][j+1]<='9') Then
                    Begin
                      For q:=(j+1) to Length(a[i]) Do
                        right:=right*10+(Ord(a[i][q])-Ord('0'));
                      Delete(a[i],j,Length(a[i])-j+1);
                      Break;
                    End
                  Else
                    If a[i][j+1]='-' Then
                      Begin
                        For q:=(j+2) to Length(a[i]) Do
                          left:=left*10+(Ord(a[i][q])-Ord('0'));
                        Delete(a[i],j,Length(a[i])-j+1);
                        Break;