QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#461967 | #5037. 回文 | grass8cow# | 10 | 90ms | 48988kb | C++17 | 2.1kb | 2024-07-03 11:21:59 | 2024-07-03 11:22:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,q;
char c[201000],b[401000],a[400100];
int kmp[401000];
int bru(int m){
for(int i=1;i<=m;i++)a[m-i+1]=a[i+m]=b[i];
for(int i=2,j=0;i<=m*2;i++){
while(j&&a[j+1]!=a[i])j=kmp[j];
if(a[j+1]==a[i])j++;kmp[i]=j;
}
int u=m*2,s=0;while(u)s+=(u<=m),u=kmp[u];
return s;
}
int OP[200100];
int L[200100],R[200100],X[200100];
char E[201000];
int ch[201000][26],fail[201000],len[201000],id[201000],f[201000][20],d[200100];
int gf(int p,int r){while(r-len[p]-1<=0||c[r-len[p]-1]!=c[r])p=fail[p];return p;}
int main(){
scanf("%s",c+1);n=strlen(c+1);
scanf("%d",&q);
/*if(n<=5000&&q<=5000){
int lans=0;
for(int i=1,op,x,l,r;i<=q;i++){
char e[2];
scanf("%d",&op);
if(op==1){scanf("%d%s",&x,e),x^=lans;c[x]=e[0];}
else{
scanf("%d%d",&l,&r);
l^=lans,r^=lans;
for(int j=l;j<=r;j++)b[j-l+1]=c[j];
printf("%d\n",lans=bru(r-l+1));
}
}
return 0;
}*/
bool fla=0;
for(int i=1;i<=q;i++){
scanf("%d",&OP[i]);
if(OP[i]==1){fla=1;char o[2];scanf("%d%s",&X[i],o),E[i]=o[0];}
else scanf("%d%d",&L[i],&R[i]);
}
if(!fla){
int cn=1,p=1;
len[1]=-1,fail[0]=1;
for(int i=1;i<=n;i++){
p=gf(p,i);int z=c[i]-'a';
if(!ch[p][z]){
fail[++cn]=ch[gf(fail[p],i)][z],ch[p][z]=cn;
d[cn]=d[fail[cn]]+1;
len[cn]=len[p]+2;
}
p=ch[p][z];
id[i]=p;
}
for(int i=2;i<=cn;i++){
f[i][0]=max(1,fail[i]);
for(int j=1;j<20;j++)f[i][j]=f[f[i][j-1]][j-1];
}
int lans=0;
for(int i=1,l,r;i<=q;i++){
l=L[i],r=R[i],l^=lans,r^=lans;
int u=id[r];
if(len[u]>r-l+1){
for(int j=19;j>=0;j--)if(f[u][j]&&len[f[u][j]]>r-l+1)u=f[u][j];
u=f[u][0];
}
printf("%d\n",lans=d[u]);
}
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 9960kb
input:
aabbbabbbaaaaaaabbabbbaaaabaaaabbaabbaabbaaababbbabbbbabbbbaaaabbbabbbbbaaabbbabbaaaaabbbbbaaababbabbaaaaabaabbbbaaababaaabbaabbabbbabbbbaaaaabbbbbbbabbbaabbbabbabbbababbabbbbaaaaabbaababbbbaabbaaaaaabaaabbbaaababbbbaabaaaaababababbbbbbaaaabbbbaaababaaabbaabbbbbaaaabbaaaabaaaaaababbababaaaabaaababaa...
output:
result:
wrong answer Unexpected EOF in the participants output
Subtask #2:
score: 10
Accepted
Test #15:
score: 10
Accepted
time: 90ms
memory: 48432kb
input:
aabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaabbbaaabbaabbbbaabbaaabbbaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaabbaaabaaaaaabaaabbaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabb...
output:
41 43 154 118 55 165 48 163 119 207 147 145 33 67 114 124 154 9 104 307 102 73 39 364 79 177 53 39 88 264 77 114 79 195 150 153 157 46 129 136 147 25 309 11 12 258 259 133 355 50 116 336 13 127 18 34 122 161 38 99 290 92 355 166 59 152 41 182 103 282 166 23 86 173 32 122 60 127 287 20 83 214 119 144...
result:
ok 200000 tokens
Test #16:
score: 0
Accepted
time: 69ms
memory: 47320kb
input:
beebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebccbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeeb...
output:
38 55 18 35 62 44 48 20 70 35 36 42 40 11 14 13 67 54 61 70 51 27 62 18 39 52 53 53 34 57 53 46 28 22 15 64 32 44 11 11 57 35 21 45 32 39 42 27 31 51 28 31 18 12 25 41 55 37 42 17 38 33 21 29 54 15 43 24 17 42 63 19 32 49 17 21 50 62 52 56 49 56 18 24 17 22 26 18 60 31 24 59 58 69 18 16 38 39 54 48 ...
result:
ok 200000 tokens
Test #17:
score: 0
Accepted
time: 63ms
memory: 48988kb
input:
cgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagcaidiaaidiacgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccg...
output:
17 15 19 21 17 18 21 12 12 15 18 20 14 14 16 20 15 19 11 17 10 20 16 16 16 19 12 17 16 15 18 12 24 20 12 19 9 17 13 21 28 10 13 17 10 14 13 24 17 17 19 24 11 18 16 14 13 13 17 13 22 21 20 14 7 11 18 15 18 12 12 12 19 14 15 16 19 20 16 23 19 16 18 13 24 22 17 13 15 21 21 22 13 21 19 20 9 20 14 14 15 ...
result:
ok 200000 tokens
Test #18:
score: 0
Accepted
time: 63ms
memory: 48504kb
input:
rprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprxrprkrprxrprmrprxrprwrprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprxrprkrprxrprmrprxrprvrprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprxrprkrprxrprmrprxrprwrprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprxrprkrprxrprmrprxrprbrprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprx...
output:
7 8 5 9 9 6 8 8 7 7 8 12 4 9 8 8 9 11 10 9 8 10 5 6 5 10 11 6 6 10 7 3 12 9 6 12 10 7 13 9 10 8 7 7 9 9 13 9 11 11 7 11 5 5 3 9 10 7 10 12 11 12 9 9 11 12 8 4 6 8 12 10 5 4 7 10 4 7 6 4 8 6 5 9 7 9 12 10 8 11 7 11 8 7 8 6 8 9 8 10 9 5 8 5 11 8 8 7 5 3 11 8 10 6 10 10 8 9 4 5 9 8 7 10 7 4 7 10 11 9 9...
result:
ok 200000 tokens
Test #19:
score: 0
Accepted
time: 56ms
memory: 47188kb
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998...
result:
ok 200000 tokens
Test #20:
score: 0
Accepted
time: 43ms
memory: 47320kb
input:
susjsusosusjsusgsusjsusosusjsusmsusjsusosusjsusgsusjsusosusjsusnsusjsusosusjsusgsusjsusosusjsusmsusjsusosusjsusgsusjsusosusjsusysusjsusosusjsusgsusjsusosusjsusmsusjsusosusjsusgsusjsusosusjsusnsusjsusosusjsusgsusjsusosusjsusmsusjsusosusjsusgsusjsusosusjsusisusjsusosusjsusgsusjsusosusjsusmsusjsusosusj...
output:
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ...
result:
ok 200000 tokens
Subtask #3:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 24ms
memory: 7892kb
input:
abbaaaabbabaaaaaabaabbaabbababbaaabbabbbabaabaabaaaaabaabbbbabbabbabbbababbbababababbbbabaabbaaababbbbbababbbbaabbbaaabaababababaabbbbbbaababaabbaaabaabbaaababbabbabbbbaaaaabaaabbbabbbbbbabbbabbabaabbbbbbbaaaabbaaaababbbaaaaaaababaabbbbaaabaaabbaabbbbbbababbaabbaaabbabbbbbabaababbaabaaaabbbbabababba...
output:
result:
wrong answer Unexpected EOF in the participants output
Subtask #4:
score: 0
Wrong Answer
Test #27:
score: 0
Wrong Answer
time: 22ms
memory: 10132kb
input:
babbaaabbbbbbbabbbababaabbbbbababababbaabaabbbbbbabbbbbbbbbbababbbbabbaabbbaabaabbabbbaabbabbbabbababaababbbabbbbaabbabbabbaaaabbbaaabbbbaabbaaaaaaabbbabbbaaabaababaaabaaaabaaaababaaaaababaaaabaabbaaaabbbabbaabaabbbabbbbbaaabaababbbaaaaabbbbaaabbbbaabbabbbbabbbabbaaaaabaabaaaabbbabbbbbaabbbbabbbbaab...
output:
result:
wrong answer Unexpected EOF in the participants output
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%