记录编号 19045 评测结果 AAAAAAAAAAAAAAAA
题目名称 翻译玛雅著作 最终得分 100
用户昵称 Gravatarmaxiem 是否通过 通过
代码语言 Pascal 运行时间 0.790 s
提交时间 2010-09-28 10:24:27 内存使用 0.11 MiB
显示代码纯文本
program writing;
var
  gf,f:array ['A'..'z'] of longint;
  ch,g,s:ansistring;
  ans,lch,lg,ls,i,j:longint;
function judge:boolean;
var i:longint;
begin
  for i:=1 to lch do begin
    if f[ch[i]]<>gf[ch[i]] then begin
	  exit (false);
	end;
  end;
  judge:=true;
end;
begin
  fillchar (gf,sizeof(gf),0);
  fillchar (f,sizeof(f),0);
  assign (input,'writing.in');
  reset (input);
  readln (lg,ls);
  readln (g);
  readln (s);
  close (input);
  assign (output,'writing.out');
  rewrite (output);
  ans:=0;
  for i:=1 to lg do begin
    inc(gf[g[i]]);
	if pos(g[i],ch)=0 then ch:=ch+g[i];
  end;
  lch:=length(ch);
  for i:=1 to lg do inc(f[s[i]]);
  if judge then inc(ans);
  i:=2;
  while i<=ls-lg+1 do begin
    dec(f[s[i-1]]);
	inc(f[s[i-1+lg]]);
	if judge then inc(ans);
        inc(i);
  end;
  writeln (ans);
  close (output);
end.