QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793455#464. 前缀函数 / KMPSin_WattWA 0ms3528kbC++14796b2024-11-29 20:05:342024-11-29 20:05:34

Judging History

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

  • [2024-11-29 20:05:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3528kb
  • [2024-11-29 20:05:34]
  • 提交

answer

#include <bits/stdc++.h>

typedef long long lnt;

using namespace std;

const int N = 1e5 + 7;

int n;
char s[N];
int ne[N];

void INIT() { }

void WORK() {
    cin >> (s + 1);
    n = strlen(s + 1);
    for (int i = 2, j = 1; i <= n; ++ i) {
        while (j && s[j + 1] != s[i]) j = ne[j];
        if (s[j + 1] == s[i]) ++ j;
        ne[i] = j;
    }
    for (int i = 1; i <= n; ++ i) {
        cout << ne[i] << '\n';
    }
}

//#define filename ""

int main() {
    #ifdef filename
    freopen(filename ".in", "r", stdin);
    freopen(filename ".out", "w", stdout);
    #endif
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(0);		
    
    int Turn = 1;
    cin >> Turn;
    INIT();
    while (Turn -- ) {
        WORK();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3528kb

input:

mencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimen...

output:


result:

wrong answer Answer contains longer sequence [length = 100000], but output contains 0 elements