A 山坡探险
         画图做吧,考差分的。注意到如果存在合法的山坡,一定是恰好走了hn-h0,然后其他的都抵消了。
 
 Codeuses math;
var m,n,hi,hn,t,count:longint;
    ch:char;
begin
readln(n,hi,hn);
while not eoln do begin
  read(ch);inc(m);
  case ch of
    'U':t:=1;
    'D':t:=-1;
    end;
  inc(hi,t);
  while hi<0 do begin
    inc(count);
    inc(hi);
    end;
  end;
if(count>n-m)or
  (abs(hn-hi)+count>n-m)or
  ((((n-m)-abs(hn-hi)-count)and 1)=1)
  then writeln('T_T')
   else writeln('lala');
end.
//==========
uses math;
var temp,d,m,n,h0,hn,sum,t,lowest:longint;
    ch:char;
begin
readln(n,h0,hn);
d:=hn-h0;sum:=0;lowest:=2;
while not eoln do begin
  read(ch);inc(m);
  case ch of
    'U':t:=1;
    'D':t:=-1;
    end;
  inc(sum,t);
  lowest:=min(lowest,sum);
  end;
t:=d-sum;temp:=(n-m-abs(t))>>1;
if(abs(t)>(n-m))or
  (((n-m-abs(t))and 1)=1)or
  ((h0+lowest<0)and(t<=0)and(h0+lowest+temp<0))or
  ((h0+lowest<0)and(t>=0)and(h0+lowest+temp+t<0))
   then writeln('T_T')
   else writeln('lala');
end.
Codeuses math;
var m,n,hi,hn,t,count:longint;
    ch:char;
begin
readln(n,hi,hn);
while not eoln do begin
  read(ch);inc(m);
  case ch of
    'U':t:=1;
    'D':t:=-1;
    end;
  inc(hi,t);
  while hi<0 do begin
    inc(count);
    inc(hi);
    end;
  end;
if(count>n-m)or
  (abs(hn-hi)+count>n-m)or
  ((((n-m)-abs(hn-hi)-count)and 1)=1)
  then writeln('T_T')
   else writeln('lala');
end.
//==========
uses math;
var temp,d,m,n,h0,hn,sum,t,lowest:longint;
    ch:char;
begin
readln(n,h0,hn);
d:=hn-h0;sum:=0;lowest:=2;
while not eoln do begin
  read(ch);inc(m);
  case ch of
    'U':t:=1;
    'D':t:=-1;
    end;
  inc(sum,t);
  lowest:=min(lowest,sum);
  end;
t:=d-sum;temp:=(n-m-abs(t))>>1;
if(abs(t)>(n-m))or
  (((n-m-abs(t))and 1)=1)or
  ((h0+lowest<0)and(t<=0)and(h0+lowest+temp<0))or
  ((h0+lowest<0)and(t>=0)and(h0+lowest+temp+t<0))
   then writeln('T_T')
   else writeln('lala');
end.
 
B 外星人
        beautifulword(T1)及其逆串(T2)是模版串,分别跟主串S1及其逆串S2做KMP得到L,R数组,L[i]代表最长的S1[1..i]的后缀跟T1前缀相等的长度,R同理。存在L[i]+R[j]>=length(s) (i<j)就能看见。

 Codeprogram C9B;
uses math;
const Filename='C9B';maxn=10000;
type  Tarray=array[1..maxn] of integer;
var   T1,T2,S1,S2:ansistring;
      temp,L,R,prefix:Tarray;
      v,i,n,m,ans:integer;
procedure OpenFile;
          begin
          Assign(Input,Filename+'.in');
          Assign(Output,Filename+'.out');
          Reset(Input);Rewrite(Output);
          end;
procedure CloseFile;
          begin close(input);close(Output);end;
procedure KMP(var s,t:ansistring;var fix:Tarray);
          var k,i:integer;
          begin
          k:=0;Prefix[1]:=0;
          for i:=2 to m do begin
            while(k>0)and(T[k+1]<>T[i])do k:=Prefix[k];
            if T[k+1]=T[i] then inc(k);
            Prefix[i]:=k;end;
          k:=0;
          for i:=1 to n do begin
            while(k>0)and(T[k+1]<>S[i])do k:=Prefix[k];
            if T[k+1]=S[i] then inc(k);
            fix[i]:=k;end;
          for i:=2 to N do fix[i]:=max(fix[i],fix[i-1]);
          end;
procedure change(var s,t:ansistring);
          var i,n:integer;
          begin
          n:=length(s);t:=s;
          for i:=1 to n do T[i]:=S[n-i+1];
          end;
function  cansee:boolean;
          var i:integer;
          begin
          readln(T1);m:=length(T1);
          cansee:=false;
          if(m>1)and(m<=n) then
            begin
            change(T1,T2);
            KMP(S1,T1,L);KMP(S2,T2,R);
            for i:=1 to n-1 do
              if(L[i]+R[n-i]>=m)
                then exit(true);
            end;
          end;
begin
openfile;readln(S1);
n:=length(S1);
change(S1,S2);
readln(V);
for i:=1 to V do
  if cansee
    then inc(ans);
writeln(ans);closefile;
end.
Codeprogram C9B;
uses math;
const Filename='C9B';maxn=10000;
type  Tarray=array[1..maxn] of integer;
var   T1,T2,S1,S2:ansistring;
      temp,L,R,prefix:Tarray;
      v,i,n,m,ans:integer;
procedure OpenFile;
          begin
          Assign(Input,Filename+'.in');
          Assign(Output,Filename+'.out');
          Reset(Input);Rewrite(Output);
          end;
procedure CloseFile;
          begin close(input);close(Output);end;
procedure KMP(var s,t:ansistring;var fix:Tarray);
          var k,i:integer;
          begin
          k:=0;Prefix[1]:=0;
          for i:=2 to m do begin
            while(k>0)and(T[k+1]<>T[i])do k:=Prefix[k];
            if T[k+1]=T[i] then inc(k);
            Prefix[i]:=k;end;
          k:=0;
          for i:=1 to n do begin
            while(k>0)and(T[k+1]<>S[i])do k:=Prefix[k];
            if T[k+1]=S[i] then inc(k);
            fix[i]:=k;end;
          for i:=2 to N do fix[i]:=max(fix[i],fix[i-1]);
          end;
procedure change(var s,t:ansistring);
          var i,n:integer;
          begin
          n:=length(s);t:=s;
          for i:=1 to n do T[i]:=S[n-i+1];
          end;
function  cansee:boolean;
          var i:integer;
          begin
          readln(T1);m:=length(T1);
          cansee:=false;
          if(m>1)and(m<=n) then
            begin
            change(T1,T2);
            KMP(S1,T1,L);KMP(S2,T2,R);
            for i:=1 to n-1 do
              if(L[i]+R[n-i]>=m)
                then exit(true);
            end;
          end;
begin
openfile;readln(S1);
n:=length(S1);
change(S1,S2);
readln(V);
for i:=1 to V do
  if cansee
    then inc(ans);
writeln(ans);closefile;
end.
 
C  Xor & Sum  感觉完全做不来
 
总结 就当复习KMP了。另外我B题KMP函数这个写法,不会爆栈吧,既然都是变参了。怎么看我程序占用的栈空间?200分可以排第4,但是我只做了100….