为啥Compile Error
查看原帖
为啥Compile Error
239823
真_小强楼主2024/10/1 00:28

请问这个为啥Compile Error呀 在线编译器和DEVC++都可以正常跑

#include<bits/stdc++.h>
using namespace std;

const int N = 1e6+10;

int n,m;
char p[N],s[N];
int ne[N];

int main()
{
	cin>>s+1>>p+1;
	n=strlen(p+1);
	m=strlen(s+1);
	//cout<<n<<m;
	for(int i=2,j=0;i<=n;i++)
	{
		while(j&&p[i]!=p[j+1]) j=ne[j];
		if(p[i]==p[j+1]) j++;
		ne[i]=j;
	}
	for(int i=1,j=1;i<=m;i++)
	{
		while(j&&s[i]!=p[j+1]) j=ne[j];
		if(s[i]==p[j+1]) j++;
		if(j==n)
		{
			printf("%d\n",i-n+1);
			j=ne[j];
		}
	}
	for(int j=1;j<=n;j++)
		printf("%d ",ne[j]);
	return 0;
}
2024/10/1 00:28
加载中...