QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#475920#464. 前缀函数 / KMPhcng#WA 3ms6180kbC++14579b2024-07-13 17:08:472024-07-13 17:08:50

Judging History

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

  • [2024-07-13 17:08:50]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6180kb
  • [2024-07-13 17:08:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int n;
char s[100010];
int b[100010];
char buf[10000000], *o = buf;

void write(int x) {if(x>9)write(x/10);*o++='0'+x%10;}


signed main() {
    // fread(s + 1, 1, 100009, stdin);
    scanf("%s", s + 1);
    n = strlen(s + 1);
    write(0); *o++=' ';
    for (int i = 2; i <= n; i++) {
        b[i] = b[i - 1];
        while (b[i] && s[b[i] + 1] != s[i]) b[i] = b[b[i]];
        if (s[b[i] + 1] == s[i]) b[i]++;
        write(b[i]); *o++=' ';
    }
    fwrite(buf, 1, 10000000, stdout);
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 6180kb

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:

wrong answer Output contains longer sequence [length = 100001], but answer contains 100000 elements