QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340545#464. 前缀函数 / KMPwtcqwq#WA 7ms4452kbC++14329b2024-02-29 09:59:112024-02-29 09:59:11

Judging History

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

  • [2024-02-29 09:59:11]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:4452kb
  • [2024-02-29 09:59:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=100009;
ll kmp[N];
int main(){
	string b;
	cin>>b;
	b=" "+b;
	ll j=0;
	for(ll i=2;i<b.size();i++){
		while(j!=0&&b[j+1]!=b[i]) j=kmp[j];
		if(b[j+1]==b[i]){
			j++;
			kmp[i]=j;
		}
	}
	for(ll i=0;i<b.size();i++) cout<<kmp[i]<<" ";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 4452kb

input:

mencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimen...

output:

0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 6...

result:

wrong answer 6th numbers differ - expected: '1', found: '0'