Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
晕哦,这样居然TLE了In Reply To:不是已经说了没错 Posted by:windbells at 2005-05-02 22:13:40 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator