ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#210909 | #2067. 肉夹馍 | mygr | 0 | 0ms | 1152kb | C++ | 685b | 2024-08-08 09:54:05 | 2024-08-08 14:27:55 |
answer
#include<bits/stdc++.h>
using namespace std;
const int Max=3e5+5;
int fail[Max],now,pre[Max];
char ch[Max];
int n;
char getc()
{
char c=getchar();
while(c<'a' or 'z'<c)
c=getchar();
return c;
}
int main()
{
ch[1]=getchar();
while('a'<=ch[n+1] and ch[n+1]<='z')
{
n++;
ch[n+1]=getchar();
}
now=0;
for(int i=2;i<=n;i++)
{
while(now and ch[now+1]!=ch[i])
now=pre[now];
if(ch[now+1]==ch[i])
now++;
pre[i]=now;
}
printf("0 ");now=0;
fail[1]=0;
for(int i=2;i<=n;i++)
{
while(now and ch[now+1]!=ch[i])
now=pre[now];
if(ch[now+1]==ch[i] and now+1<=(i-1)/2)
now++;
fail[i]=now;
printf("%d ",now);
}
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1152kb
input:
qpbvqpbvqpbvavdqpbvqpbvqpbvavdqpbvqpbvqpbvavdfnfninqpbvqpbvqpbvavdqpbvqpbvqpbvavdqpbvqpbvqpbvavd
output:
0 0 0 0 1 2 3 3 1 2 3 4 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1...
result:
wrong answer 8th words differ - expected: '0', found: '3'
Subtask #2:
score: 0
Skipped
Subtask #3:
score: 0
Skipped
Subtask #4:
score: 0
Skipped