比赛 20100927 评测结果 AAAAAAAAAAAAAAAA
题目名称 翻译玛雅著作 最终得分 100
用户昵称 donny 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-09-27 20:20:44
显示代码纯文本
program writing(input,output);
var
  i,j,max,k:longint;
  n,m:longint;
  a:array[1..3000000]of char;
  s:array['A'..'z']of longint;
  q:array['A'..'z']of longint;
  c:char;
  b:boolean;
function pan:boolean;
var
  c:char;
begin
  for c:='A' to 'z' do
    if s[c]<>q[c] then exit(false);
  exit(true);
end;
begin
  assign(input,'writing.in');
  reset(input);
  assign(output,'writing.out');
  rewrite(output);

  readln(n,m);
  for c:='A' to 'z' do
  begin
    s[c]:=0;
    q[c]:=0;
  end;
  for i:=1 to n do
  begin
    read(c);
    inc(s[c]);
  end;
  readln;
  for i:=1 to m do
  begin
    read(a[i]);
  end;
  readln;
  for i:=1 to n do
    inc(q[a[i]]);
  if pan then max:=1 else max:=0;
  for i:=n+1 to m do
  begin
    dec(q[a[i-n]]);
    inc(q[a[i]]);
    if pan then inc(max);
  end;
  writeln(max);
  close(input);
  close(output);
end.