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 1002. Phone Numbers

why no compile , it's right on freepascal
Posted by caocao9926 29 Nov 2007 18:43
it's right on freepascal 2.2.0
but no compile on ural

why help

program cao;
var
  a:array[1..2,1..5000] of string;
  b,c,d,e,f,g,h,j,k,l,i,n,m,p,q:longint;
  s,s1,s2,s3:string;
  flag:boolean;

function work(a:ansistring):ansistring;
var
  i,j,k,l:longint;
begin
  work:='';
  for i:=1 to length(a) do
    case a[i] of
      'i','j':work:=work+chr(49);
      'a','b','c':work:=work+chr(50);
      'd','e','f':work:=work+chr(51);
      'g','h':work:=work+chr(52);
      'k','l':work:=work+chr(53);
      'm','n':work:=work+chr(54);
      'p','r','s':work:=work+chr(55);
      't','u','v':work:=work+chr(56);
      'w','y','x':work:=work+chr(57);
      'o','q','z':work:=work+chr(48);
    end;
end;
procedure search(depth:longint);
var
  i:longint;
begin
  if length(s1)>length(s)then exit;
  if (pos(s1,s)<>1)and(s1<>'') then exit;
  if s1=s then
  begin
    if flag= false then s3:=s2;
    flag:=true;
    if length(s3)>length(s2) then s3:=s2;
    exit;
  end;
  for i:=1 to n do
  begin
    s1:=s1+a[2,i];
    s2:=s2+' '+a[1,i];
    search(depth+1);
    delete(s1,length(s1)-length(a[2,i])+1,length(a[2,i]));
    delete(s2,length(s2)-length(' '+a[1,i])+1,length(' '+a[1,i]));
  end;
end;
begin
  while true do
  begin
    readln(s);
    if s='-1' then halt;
    readln(n);
    for i:=1 to n do
    begin
      readln(a[1,i]);
      a[2,i]:=work(a[1,i]);
    end;
    flag:=false;
    s1:='';
    s2:='';
    search(1);
    if flag then delete(s3,1,1);
    if flag then writeln(s3);
    if flag=false then writeln('No solution.');
  end;
end.



You tried to solve problem 1002 Phone numbers.
Your solution was compiled with the following errors:

a2f28f32-d345-45d7-b4e3-6d89858507f9(15,25) Error: Incompatible types: got "work(AnsiString):AnsiString" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(15,33) Error: Incompatible types: got "Char" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(16,29) Error: Incompatible types: got "work(AnsiString):AnsiString" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(16,37) Error: Incompatible types: got "Char" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(17,29) Error: Incompatible types: got "work(AnsiString):AnsiString" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(17,37) Error: Incompatible types: got "Char" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(18,25) Error: Incompatible types: got "work(AnsiString):AnsiString" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(18,33) Error: Incompatible types: got "Char" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(19,25) Error: Incompatible types: got "work(AnsiString):AnsiString" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(19,33) Error: Incompatible types: got "Char" expected "LongInt"
a2f28f32-d345-45d7-b4e3-6d89858507f9(19,33) Fatal: There were 10 errors compiling module, stopping
a2f28f32-d345-45d7-b4e3-6d89858507f9(19,33) Fatal: Compilation aborted
Re: why no compile , it's right on freepascal
Posted by Alias (Alexander Prudaev) 29 Nov 2007 19:44
try to use "Result" instead of "work" in function "work":

function work(...)

begin
  Result := '';
  Result := Result + chr(..)....
end;