QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#129265 | #464. 前缀函数 / KMP | zyz07# | WA | 3ms | 3964kb | C++17 | 563b | 2023-07-22 13:13:48 | 2023-07-22 13:13:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define For(Ti,Ta,Tb) for(auto Ti=(Ta);Ti<=(Tb);++Ti)
#define Dec(Ti,Ta,Tb) for(auto Ti=(Ta);Ti>=(Tb);--Ti)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define range(Tx) begin(Tx),end(Tx)
using ll=long long;
const int N=1e5+5;
int n,kmp[N];
char s[N];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin>>(s+1);
n=strlen(s+1);
for(int i=2,j=0;i<=n;++i){
while(j&&s[j+1]!=s[i+1]) j=kmp[j];
if(s[j+1]==s[i+1]) ++j;
kmp[i]=j;
}
For(i,1,n) cout<<kmp[i]<<" \n"[i==n];
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3964kb
input:
mencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimen...
output:
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 63 64...
result:
wrong answer 5th numbers differ - expected: '0', found: '1'