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 1989. Subpalindromes

Help
Posted by Evgeniy 9 Jun 2018 16:44
I cant understand my mistake for TLE14.
My code
var
    s,s1,s2: string;
    z2,z1,a,i,f,p,code: integer;z,n:int64;
    ch:char;
begin
    readln(s);
    readln(npalindrome? 1 100000);
    for i:=1 to n do
    begin
        readln(s2);
        if s2[1]='p' then
        begin
        a:=13;z1:=0;z2:=0;
            while s2[a]<>' ' do
            inc(a);
         val(copy(s2,13,a-13),z1,code);
         val(copy(s2,a+1,length(s2)-1),z2,code);
             z:=z2-z1+1;
             if z2>length(s) then z2:=length(s);
            s1:=copy(s,z1,z);

             f := 1;
             p:=1;
             while (p<=length(s1)div 2)and(f<>0)  do
             if (s1[p] <> s1[length(s1)-p+1]) then
             begin
                  writeln('No');
                  f := 0;
             end else
             p:=p+1;

             if f = 1 then
             writeln('Yes');
        end else
        begin
        a:=8;z1:=0;
           while s2[a]<>' ' do
           inc(a);
                 Val(copy(s2,8,a-8),z1,code);
             ch:=s2[a+1];
             delete(s,z1,1);
             insert(ch,s,z1);

        end;
    end;
end.