[字符串] kmp模板题 HDU1711

大概复习了下,裸的kmp,其实这个对我来说重点不是kmp而是学到的新快读挂。。。当发现自己裸读800ms,加快读挂140ms然后前排聚聚还是能90ms的时候就去翻了下他们代码然后发现了这个神奇的,,我本地 甚至不能正常运行的快读。。Oooooooorz。。。

#include 
#include 
#include 
#include
#include
#include
#include
#include
#include
//#include
#include
#include
using namespace std;
typedef long long LL;
const int maxn=1e6+5;
const int MOD=20071027;
const int BufferSize=1<<16;
char buffer[BufferSize],*head,*tail;
inline char Getchar()
{
    if(head==tail)
    {
        int l=fread(buffer,1,BufferSize,stdin);
        tail=(head=buffer)+l;
    }
    return *head++;
}
inline int read()
{
    int x=0,f=1;
    char c=Getchar();
    for (;!isdigit(c);c=Getchar())if(c=='-')f=-1;
    for (;isdigit(c);c=Getchar())x=x*10+c-'0';
    return x*f;
}

int a[maxn],p[10005],nex[10005],N,M;

void getFail()
{
    nex[0]=nex[1]=0;
    int j;
    for (int i=1;i
	

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据