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 1067. Disk Tree

HELP WA6
Posted by +FAMAS+ 14 Jan 2006 03:16
type
str = string;
var
  a:array[1..500] of str;
  i,j,n,t,p,f,l:integer;
  s:str;
function sort(t1,t2:integer):boolean;
var
i,n:integer;
begin
i:=0;
sort:=false;
if length(a[t1])>length(a[t2]) then n:=length(a[t2]) else n:=length(a[t1]);
while i<n  do
   begin
   inc(i);
   if ((a[t1][i]>a[t2][i]) and ((a[t1][i]<>'\') and (a[t2][i]<>'\')))
   or ((a[t2][i]='\') and (a[t1][i]<>'\')) then
        begin
          s:=a[t1];
          a[t1]:=a[t2];
          a[t2]:=s;
          i:=n;
          sort:=true;
        end else
   if (a[t1][i]<a[t2][i]) or ((a[t1][i]='\') and (a[t2][i]<>'\')) then i:=n
   end;
end;
procedure kor(k:str; z:integer);
var
i:integer;
begin
   t:=1;
   for i:=1 to length(k) do
   if k[i]='\' then
     begin
      s:=copy(k,t,i-t);
      t:=i+1;
      writeln(s:(length(s)+z));
      inc(z);
     end;
end;
begin
{   assign(input,'c:\test.txt'); reset(input);}
   readln(n);
   for i:=1 to n do begin readln(a[i]); a[i]:=a[i]+'\'; end;
   i:=0;
   while i<n-1 do
   begin
    inc(i);
    if sort(i,i+1) then i:=0;
   end;
   kor(a[1],0);
   for i:=2 to n do
     begin
       t:=0; f:=0;
       if length(a[i-1])<length(a[i]) then l:=length(a[i]) else l:=length(a[i-1]);
       for j:=1 to l do
         if a[i][j]<>a[i-1][j] then break
         else if a[i][j]='\' then begin t:=j; inc(f); end;
       s:=a[i];
       if t=0 then kor(s,t) else begin  delete(s,1,t); kor(s,f); end;
     end;
 {  close(input);}
end.

and if i change str = string => str = string[90] i have wa5?!!!!
i have AC:)
Posted by +FAMAS+ 14 Jan 2006 03:47
but
and if i change str = string => str = string[90] i have wa5?!!!!