比赛 20100927 评测结果 AAAAAAAAAAAATTTT
题目名称 翻译玛雅著作 最终得分 75
用户昵称 1102 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-09-27 20:47:57
显示代码纯文本
program xxxx;
var s:array[1..3000000] of char;
    g:array[1..3000] of char;
    ch1,ch2:array['A'..'z'] of longint;
    m,n,i,j,flag,x:longint;
    chr:char;
begin
  assign(input,'writing.in');
  reset(input);
  assign(output,'writing.out');
  rewrite(output);
  readln(n,m);
  for i:=1 to n do
    begin
      read(g[i]);
      inc(ch1[g[i]]);
    end;
  readln;
  for i:=1 to m do
    read(s[i]);
  for i:=1 to m-n+1 do
    begin
      flag:=0;
      for chr:='A' to 'z' do
        ch2[chr]:=0;
      for j:=i to i+n-1 do
        begin
          inc(ch2[ s[j] ]);
          if ch2[ s[j] ]>ch1[ s[j] ] then
            begin
              flag:=1;
              break;
            end;
        end;
      if flag<>1 then
        inc(x);
    end;
  write(x);
  close(input);
  close(output);
end.