记录编号 20485 评测结果 AAAAAAAAAAAAAAAA
题目名称 翻译玛雅著作 最终得分 100
用户昵称 Gravatarbelong.zmx 是否通过 通过
代码语言 Pascal 运行时间 1.535 s
提交时间 2010-10-26 14:10:33 内存使用 2.97 MiB
显示代码纯文本
program writing(input,output);
var
 a:array[1..3000000]of char;
 b1,b2:array['0'..'z']of longint;
 i,j:longint;
 g,s:longint;
 ans:longint;
 ch:char;

function fuck(x:longint):boolean;
var
 p:char;
begin
 fuck:=true;
 for p:='0' to '9' do
 begin
  if b2[p]<>b1[p] then
  begin
   fuck:=false;
   exit;
  end;
 end;
 for p:='A' to 'Z' do
  if b2[p]<>b1[p] then
  begin
   fuck:=false;
   exit;
  end;
 for p:='a' to 'z' do
  if b2[p]<>b1[p] then
  begin
   fuck:=false;
   exit;
  end;
end;

begin
 assign(input,'writing.in');
 reset(input);
 readln(g,s);
 for i:=1 to g do
 begin
  read(ch);
  inc(b1[ch]);
 end;
 readln;
 for i:=1 to s do read(a[i]);
 close(input);

 for i:=1 to g do
  inc(b2[a[i]]);

 if fuck(0) then inc(ans);
 for i:=1 to s-g do
 begin
  dec(b2[a[i]]);
  inc(b2[a[i+g]]);
  if fuck(i) then inc(ans);
 end;

 assign(output,'writing.out');
 rewrite(output);
 writeln(ans);
 close(output);
end.