比赛 20100927 评测结果 AAAAAAAAAAAAAAAA
题目名称 翻译玛雅著作 最终得分 100
用户昵称 苏轼 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-09-27 21:24:31
显示代码纯文本
program writing(input,output);

type
  arr=array['A'..'z']of longint;

var
  i,l1,l2,ans,len:longint;
  ch:char;
  a,b:arr;
  sym:array[1..3000000]of char;


function same:boolean;
  var
    i:char;
  begin
    for i:='A' to 'Z' do
      if a[i]<>b[i] then
        exit(false);

    for i:='a' to 'z' do
      if a[i]<>b[i] then
        exit(false);

    exit(true);
  end;

begin
  assign(input,'writing.in');
  reset(input);

  assign(output,'writing.out');
  rewrite(output);

  readln(l1,l2);

  for i:=1 to l1 do
  begin
    read(ch);

    inc(a[ch]);
  end;

  readln;

  for i:=1 to l1 do
  begin
    read(ch);
    inc(b[ch]);

    inc(len);
    sym[len]:=ch;
  end;

  if same then
    ans:=1;

  for i:=l1+1 to l2 do
  begin
    read(ch);

    inc(len);
    sym[len]:=ch;

    inc(b[ch]);
    dec(b[sym[len-l1]]);

    if same then
      inc(ans);
  end;

  writeln(ans);

  close(input);
  close(output);
end.