QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#473960#464. 前缀函数 / KMPhcng#RE 0ms0kbC++14547b2024-07-12 15:14:252024-07-12 15:14:26

Judging History

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

  • [2024-07-12 15:14:26]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-12 15:14:25]
  • 提交

answer

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

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

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

signed main() {
    fread(s + 1, 1, 100010, stdin);
    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, 1000000, stdout);
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

mencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimen...

output:


result: