|
|
вернуться в форумWA 3! HELP!!!! Code: const Nmax=155000; var Z,L1,R1:array[1..Nmax] of longint; A:array[1..Nmax] of char; N,M,Middle,L,R,i,j,k:longint; ch:char;
function Min(x,y:longint):longint; begin if(x>y) then x:=y; Min:=x; end;
BEGIN N:=0; read(ch); while(ord(ch)>=ord('a')) do begin inc(N); A[N]:=ch; read(ch); end; readln;
inc(N); A[N]:='#'; M:=N; read(ch); while(ord(ch)>=ord('a')) do begin inc(N); A[N]:=ch; read(ch); end;
Z[1]:=N; R:=0; L:=0;
for i:=2 to N do begin if(i<=r) then Z[i]:=min(R-i+1,Z[i-L+1]) else Z[i]:=0; while(i+z[i]<=N)and(A[i+z[i]]=A[z[i]+1]) do inc(z[i]); if(i+z[i]-1>r) then begin L:=i; R:=i+z[i]-1; end; end;
k:=0; L1[k]:=N+1; R1[k]:=N+1;
i:=N; while(i>=M+1) do begin if(i+z[i]-1>=L1[k]-1) then begin inc(k); L1[k]:=i; R1[k]:=L1[k-1]-1; end; dec(i); end;
if(L1[k]=M+1) then begin writeln('No'); while(k>0) do begin for i:=L1[k] to R1[k] do write(A[i]);write(' '); dec(k); end; end else begin writeln('Yes'); end; END.
|
|
|