比赛 NOIP_2 评测结果 AAAAAAAAAAAATTTT
题目名称 翻译玛雅著作 最终得分 75
用户昵称 zxc111 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-09-08 21:47:56
显示代码纯文本
program ooo;
var
t:text;
a,b:array[1..70] of longint;
q:array[1..3000000] of longint;
i,j,k,l,n,m,sum:longint;
c:char;
begin
assign(t,'writing.in');
reset(t);
readln(t,n,m);
for i:=1 to n do
 begin
  read(t,c);
  if c>='a' then
   begin
    j:=ord(c)-ord('a')+27;
    inc(a[j]);
   end else
   begin
    j:=ord(c)-ord('A')+1;
    inc(a[j]);
   end;
  end;
 readln(t);
for i:=1 to m do
 begin
 read(t,c);
 if c>='a' then
  begin
  j:=ord(c)-ord('a')+27;
  q[i]:=j;
  end else
   begin
    j:=ord(c)-ord('A')+1;
    q[i]:=j;
   end;
  end;
 i:=1;
 close(t);
 while i<=m-n+1 do
  begin

   for j:=i to m do
    if (b[q[j]]+1<=a[q[j]])and(k+1<=n) then
     begin
      inc(k);
      inc(b[q[j]]);
     end else
      if b[q[j]]+1>a[q[j]] then
      begin
       if k=n then
        begin
        inc(sum);
        i:=i+1;
        fillchar(b,sizeof(b),0);
        k:=0;
        break;
       end else begin
       i:=i+1;
       fillchar(b,sizeof(b),0);
       k:=0;
       break;
      end;
     end;
    end;
    assign(t,'writing.out');
    rewrite(t);
write(t,sum);
close(t);
end.