QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#479506#464. 前缀函数 / KMPGold_Dino#WA 6ms4368kbC++14429b2024-07-15 18:09:192024-07-15 18:09:19

Judging History

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

  • [2024-07-15 18:09:19]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:4368kb
  • [2024-07-15 18:09:19]
  • 提交

answer

#include <bits/stdc++.h>
const int N = 100007;
int n;
char str[N];
int pi[N];
int main()
{
    scanf("%s", str + 1), n = strlen(str + 1);
    for (int i = 2; i <= n; ++i)
    {
        pi[i] = pi[i - 1];
        while (str[pi[i] + 1] != str[i] && pi[i])
            pi[i] = pi[pi[i]];
        if (str[pi[i] + 1] == str[i])
            ++pi[i];
        printf("%d%c", pi[i], " \n"[i == n]);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 4368kb

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'