QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#91613 | #464. 前缀函数 / KMP | hy233# | WA | 9ms | 3752kb | C++14 | 601b | 2023-03-29 10:05:22 | 2023-03-29 10:05:29 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=500005;
const ll mod=998244353;
const int inf=0x3f3f3f3f;
inline int rd()
{
int x=0; bool f=1;
char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar())
if(ch=='-') f=0;
for(;ch>='0'&&ch<='9';ch=getchar())
x=x*10+(ch^48);
return f?x:-x;
}
char s[N];
int nxt[N];
int main()
{
scanf("%s",s+1);
int n=strlen(s+1);
cout<<0<<' ';
for(int i=2,j=0;i<=n;i++)
{
while(j&&s[i]!=s[j+1]) j=nxt[j];
if(s[i]==s[j+1]) j++;
cout<<j<<' ';
}
cout<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 3584kb
input:
mencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimen...
output:
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 63 ...
result:
ok 100000 numbers
Test #2:
score: 0
Accepted
time: 7ms
memory: 3472kb
input:
hyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioihyaknoipnoizjoictsapioioi...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 8...
result:
ok 100000 numbers
Test #3:
score: -100
Wrong Answer
time: 9ms
memory: 3752kb
input:
dccdcbacdadaccadcbddcccadcbaccdcaacaacaacdddadddaccacbccdcdbcbccbabaacbdccadadaadcadadbcbbccabadcbdbbabaabdbdabdacbcadadccacaadddabadcabdbddadacdcdbddccbadccdbcadddbabcbddbadbdccbcabbbcacddbdbcbdabaaabcbcbcdccaabbbbddbcbdcbcacbbbdbdbdcccbcadadbcdabdaccbdaadadcdacabbdadababadccaddbcbacdddbdaddadcabaa...
output:
0 0 0 1 2 0 0 0 1 0 1 0 0 0 0 1 2 0 1 1 2 3 0 0 1 2 0 0 0 0 1 2 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 0 1 0 1 0 0 1 2 0 1 0 1 0 0 0 0 0 0 0 0 0 1 2 0 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 0 1 2 3 0 0 0 0 1 1 1 0 0 0 1 2 0 0 1 0 1 1 0 1 0 0 1 2 1 0 1 1 ...
result:
wrong answer 404th numbers differ - expected: '3', found: '0'