QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#462076#464. 前缀函数 / KMPLynkcat#Compile Error//Python3686b2024-07-03 13:53:442024-07-03 13:53:45

Judging History

你现在查看的是最新测评结果

  • [2024-07-03 13:53:45]
  • 评测
  • [2024-07-03 13:53:44]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) (int)((x).size())
//#define int ll
//#define N
using namespace std;
void BellaKira()
{
	string st;
	cin>>st;
	int n=sz(st);
	poly g(n+1,0);
	cout<<0<<" ";
	for (int i=2,j=0;i<=n;i++)
	{
		while (j&&st[j]!=st[i-1]) j=g[j];
		if (st[j]==st[i-1]) j++;
		g[i]=j;
		cout<<j<<" ";
	}
	cout<<'\n';
		
}
signed main()
{
	IOS;
	cin.tie(0);
	int T=1;
	while (T--)
	{
		BellaKira();
	}
}

Details

  File "answer.code", line 13
    //#define int ll
    ^^
SyntaxError: invalid syntax