比赛 模拟测试2 评测结果 AAAAAAAAAAAAAAAA
题目名称 翻译玛雅著作 最终得分 100
用户昵称 make 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-10-12 19:55:47
显示代码纯文本
program writing;
var
 a,num:array ['A'..'z'] of longint;
 b:array [1..3000000] of char;
 h:array [1..52] of char;
 o:array ['A'..'z'] of boolean;
 g,s,sp,ans,f:longint;
 f1,f2:text;

procedure init;
var ch:char;  i:longint;
begin
 assign(f1,'writing.in');
 assign(f2,'writing.out');
 reset(f1);
 rewrite(f2);
 readln(f1,g,s);
 sp:=0;
 for i:=1 to g do begin
  read(f1,ch);
  if o[ch]=false then begin
   inc(sp);
   h[sp]:=ch;
   o[ch]:=true;
  end;
  a[ch]:=a[ch]+1;
 end;
 readln(f1);
 for i:=1 to s do read(f1,b[i]);
 close(f1);
 for i:=1 to g do inc(num[b[i]]);
end;

procedure play;
var i,j,k:longint;
begin
  i:=1;
  j:=g;
 while j<=s do begin
  f:=0;
  for k:=1 to sp do if num[h[k]]=a[h[k]] then f:=f+1;
  if f=sp then ans:=ans+1;
  if j<s then begin
   dec(num[b[i]]);
   inc(i);
   inc(j);
   inc(num[b[j]]);
  end else inc(j);
 end;
end;


begin
 init;
 play;
 writeln(f2,ans);
 close(f2);
end.