QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#419324 | #8701. Border | Williamxzh# | 0 | 0ms | 0kb | C++23 | 468b | 2024-05-23 20:20:21 | 2024-05-23 20:20:22 |
answer
#include <bits/stdc++.h>
#define il inline
using namespace std;
const int N=2e6+5;
int n,nxt[N];char s[N],t[N];
il int calc(){
for(int i=2,j;i<=n;++i){
while(j && s[i]!=s[j+1]) j=nxt[j];
if(s[i]==s[j+1]) ++j;
nxt[i]=j;
}return nxt[n];
}
char c;
int main(){
scanf("%s%s",s+1,t+1);n=strlen(s+1);
for(int i=1;i<=n;++i){
c=s[i],s[i]=t[i];printf("%d\n",calc());
s[i]=c;
}
return 0;
}
详细
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
cbaababaabacbaababaabacbaabacbaababaabacbaaba dabbababbabaabbafabbgbaabfebaabzababbayaabcac
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%