Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题怎么没有用Pascal过的?

Posted by JiangLY at 2005-05-02 23:04:05 on Problem 1885
In Reply To:晕哦,这样居然TLE了 Posted by:JiangLY at 2005-05-02 22:29:45
> var
>   s1:set of 'a'..'z';
>   s2:set of 'A'..'Z';
>   s3:set of '0'..'9';
>   c:char;
>   i,j,k,l,t,last,a,b:longint;
>   s,ans,p,q,y:string;
>   stack:array[1..100000] of string[50];
> begin
> //  assign(input,'1.txt');
> //  reset(input);
> //  assign(output,'1.out');
> //  rewrite(output);
>   l:=0;
>   for c:='a' to 'z' do s1:=s1+[c];
>   for c:='A' to 'Z' do s2:=s2+[c];
>   for c:='0' to '9' do s3:=s3+[c];
>   while not eof do
>     begin
>       readln(s);
>       if s='0' then halt;
>       s:=s+' ';
>       ans:='';
>       last:=1;
>       q:='';
>       for i:=1 to length(s) do
>         begin
>           if s[i] in s3 then q:=q+s[i]
>                         else
>                           begin
>                             if q<>'' then
>                               begin
>                                 val(q,a,b);
>                                 ans:=ans+stack[l-a+1];
>                                 y:=stack[l-a+1];
>                                 for j:=l-a+1 to l do stack[j-1]:=stack[j];
>                                 stack[l]:=y;
>                                 q:='';
>                               end;
>                             if i<>length(s) then ans:=ans+s[i];
>                           end;
>           if (s[i] in s1=false)and(s[i] in s2=false) then
>             begin
>               p:=copy(s,last,i-last+1);
>               while (p[1] in s1=false)and(p[1] in s2=false)and(p<>'') do delete(p,1,1);
>               while (p[length(p)] in s1=false)and(p[length(p)] in s2=false)and(p<>'') do delete(p,length(p),1);
>               last:=i;
>               if p='' then continue;
>               inc(l);
>               stack[l]:=p;
>             end;
>         end;
>       writeln(ans);
>     end;
> //  close(output);
> end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator