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 1089. Verification with the Dictionary

Why my program is wrong??? May be in input mistake??? Please? HELP ME!!! (Problem 1089)
Posted by Reshetnikov Eugeny 17 Jan 2002 10:38
Program n1089;
  Const
    voc=['a'..'z'];
  Var
    a:array [1..101] of string[10];
    b:array [1..30000] of char;
    c:array [1..30000] of boolean;
    i,j,q,w,m,n,k,count:integer;
    pp:boolean;

Procedure Input;
  Begin
    n:=0;
    While true Do
      Begin
        Inc(n);
        ReadLn(a[n]);
        If a[n]='#' Then
          Begin
            Dec(n);
            Break;
          End;
      End;
    m:=0;
    While true Do
      Begin
        Inc(m);
        Read(b[m]);
        If Ord(b[m])=26 Then
          Break;
      End;
  End;

Procedure Solve;
  Begin
    count:=0;
    Repeat
      pp:=false;
      For i:=1 to m Do
        If (b[i] in voc) and (c[i]=false) Then
          Begin
            pp:=true;
            Break;
          End;
      For j:=(i+1) to m Do
        If Not(b[j] in voc) Then
          Break;
      For q:=1 to n Do
        If Length(a[q])=(j-i) Then
          Begin
            k:=0;
            For w:=1 to Length(a[q]) Do
              If a[q][w]<>b[i+w-1] Then
                Inc(k);
            If k=1 Then
              Begin
                For w:=1 to Length(a[q]) Do
                  If a[q][w]<>b[i+w-1] Then
                    Begin
                      b[i+w-1]:=a[q][w];
                      Break;
                    End;
                Inc(count);
                Break;
              End;
          End;
      For w:=i to (j-1) Do
        c[w]:=true;
    Until Not pp;
  End;

Procedure Output;
  Begin
    For i:=1 to m Do
      Write(b[i]);
    WriteLn;
    Write(count);
  End;

Begin
  Input;
  Solve;
  Output;
End.