QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#473960 | #464. 前缀函数 / KMP | hcng# | RE | 0ms | 0kb | C++14 | 547b | 2024-07-12 15:14:25 | 2024-07-12 15:14:26 |
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;
}
详细
Test #1:
score: 0
Runtime Error
input:
mencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimencimencimencimencimenciyvdfitnmencimencimencimen...