QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#124241#464. 前缀函数 / KMPIgnotus#WA 1ms3388kbC++14354b2023-07-14 14:47:462023-07-14 14:47:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 14:47:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3388kb
  • [2023-07-14 14:47:46]
  • 提交

answer

#include <bits/stdc++.h>

const int N = 1e5 + 10;
char s[N];

int nxt[N];

int main(){
	scanf("%d", s + 1);
	int n = strlen(s + 1);
	for(int i = 2, j = 0; i <= n; ++i){
		while(j && s[j + 1] != s[i]) j = nxt[j];
		if(s[j + 1] == s[i]) ++j;
		nxt[i] = j;
	}
	for(int i = 1; i <= n; ++i) printf("%d%c", nxt[i], " \n"[i == n]);
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3388kb

input:

mencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimen...

output:


result:

wrong answer Answer contains longer sequence [length = 100000], but output contains 0 elements