1 solutions
-
0
Pascal :
var a,b:array[0..300000] of longint; i,j,k,n,m,tot:longint; c:char; procedure deal(x,y:longint); var i,j:longint; begin if x>y then exit; if x=y then begin inc(tot); b[tot]:=a[x]; exit; end; i:=x; j:=y; if a[x]<a[y] then begin inc(tot); b[tot]:=a[x]; deal(x+1,y); exit; end; if a[x]>a[y] then begin inc(tot); b[tot]:=a[y]; deal(x,y-1); exit; end; while (a[i]=a[j])and(i+1<=j-1) do begin inc(i); dec(j); end; if a[i]>=a[j] then begin inc(tot); b[tot]:=a[y]; deal(x,y-1); exit; end; if a[i]<a[j] then begin inc(tot); b[tot]:=a[x]; deal(x+1,y); exit; end; end; begin readln(n); for i:=1 to n do begin readln(c); a[i]:=ord(c)-ord('A'); end; deal(1,n); for i:=1 to n do if i mod 80=0 then writeln(chr(b[i]+ord('A'))) else write(chr(b[i]+ord('A'))); end.
- 1
Information
- ID
- 545
- Time
- 5000ms
- Memory
- 256MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By