QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#124241 | #464. 前缀函数 / KMP | Ignotus# | WA | 1ms | 3388kb | C++14 | 354b | 2023-07-14 14:47:46 | 2023-07-14 14:47:47 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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