| 记录编号 | 19216 | 评测结果 | AAAAAAAAAAAAAAAA | 
    
        | 题目名称 | 90.翻译玛雅著作 | 最终得分 | 100 | 
    
        | 用户昵称 |  kaaala | 是否通过 | 通过 | 
    
        | 代码语言 | C++ | 运行时间 | 2.175 s | 
    
        | 提交时间 | 2010-09-29 19:32:46 | 内存使用 | 3.12 MiB | 
    
    
    
    		显示代码纯文本
		
		#include <fstream>
#include <string>
using namespace std;
int s1[256],s2[256];
char s[3000000];
int n1,n2,ans;
char t;
int i;
bool try2();
void try1();
int main()
{
	ifstream fin("writing.in");
	ofstream fout("writing.out");
	fin>>n1>>n2;
	for (i=0; i<n1; i++)
	{
		fin>>t;
		s1[(int)t]++;
	}
	for (i=0; i<n2; fin>>s[i++]);
	try1();
	fout<<ans<<endl;
	fin.close();
	fout.close();
}
bool try2()
{
	int i;
	for (i=0; i<256; i++)
		if (s1[i]!=s2[i])
			return false;
	return true;
}
void try1()
{
	int i;
	for (i=0; i<n1; i++)
		s2[(int)s[i]]++;
	if (try2()) 
		ans++;
	for (; i<n2; i++)
	{
		s2[(int)s[i]]++;
		s2[(int)s[i-n1]]--;
		if (try2())
			ans++;
	}
}