QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#461969 | #5037. 回文 | grass8cow# | 10 | 269ms | 6104kb | C++17 | 827b | 2024-07-03 11:23:58 | 2024-07-03 11:23:59 |
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 main(){
scanf("%s",c+1);n=strlen(c+1);
scanf("%d",&q);
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;
l=max(l,r-100);
for(int j=l;j<=r;j++)b[j-l+1]=c[j];
printf("%d\n",lans=bru(r-l+1));
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 10
Accepted
time: 0ms
memory: 3912kb
input:
aabbbabbbaaaaaaabbabbbaaaabaaaabbaabbaabbaaababbbabbbbabbbbaaaabbbabbbbbaaabbbabbaaaaabbbbbaaababbabbaaaaabaabbbbaaababaaabbaabbabbbabbbbaaaaabbbbbbbabbbaabbbabbabbbababbabbbbaaaaabbaababbbbaabbaaaaaabaaabbbaaababbbbaabaaaaababababbbbbbaaaabbbbaaababaaabbaabbbbbaaaabbaaaabaaaaaababbababaaaabaaababaa...
output:
2 3 5 3 3 3 2 3 4 2 4 2 4 2 3 3 3 2 2 2 2 2 2 3 4 2 2 3 2 2 4 3 3 2 3 3 4 3 3 4 4 2 3 4 2 2 4 2 4 3 2 2 2 3 3 3 4 4 3 3 2 3 3 2 3 3 4 2 2 4 2 3 2 3 3 2 3 2 2 3 2 2 3 6 2 2 3 7 4 3 2 2 2 2 3 4 4 4 4 2 2 3 2 4 2 2 2 3 3 2 2 2 2 3 3 4 3 2 3 3 2 2 4 5 4 2 2 5 3 3 3 3 2 4 2 3 2 3 3 3 2 4 4 5 2 2 3 5 3 3 ...
result:
ok 2509 tokens
Test #2:
score: 0
Runtime Error
input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #15:
score: 0
Runtime Error
input:
aabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaabbbaaabbaabbbbaabbaaabbbaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaabbaaabaaaaaabaaabbaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabb...
output:
5 6 5 6 6 5 5 5 4 7 8 3 4 7 7 5 8 3 4 6 3 3 5 5 4 7 9 7 6 6 3 4 6 3 7 3 4 6 5 5 4 2 4 4 5 7 5 5 4 4 6 4 9 4 6 6 3 7 7 3 4 5 4 8 3 5 7 2 4 4 4 7 3 7 9 4 4 7 5 6 5 4 4 5 6 6 4 3 2 4 3 7 4 6 6 6 7 5 7 6 5 3 5 7 7 3 7 6 6 5 6 6 8 2 4 6 5 6 5 5 7 6 3 4 6 4 4 8 5 4 4 7 4 5 6 2 7 5 5 5 3 5 4 5 8 9 5 5 6 4 ...
result:
Subtask #3:
score: 10
Accepted
Test #21:
score: 10
Accepted
time: 27ms
memory: 4020kb
input:
abbaaaabbabaaaaaabaabbaabbababbaaabbabbbabaabaabaaaaabaabbbbabbabbabbbababbbababababbbbabaabbaaababbbbbababbbbaabbbaaabaababababaabbbbbbaababaabbaaabaabbaaababbabbabbbbaaaaabaaabbbabbbbbbabbbabbabaabbbbbbbaaaabbaaaababbbaaaaaaababaabbbbaaabaaabbaabbbbbbababbaabbaaabbabbbbbabaababbaabaaaabbbbabababba...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 8 8 8 8 ...
result:
ok 198 tokens
Test #22:
score: 10
Accepted
time: 254ms
memory: 3992kb
input:
abbaababbabababbbbabababbbaaaabababbbbaabaabbbbabbbabbaabababbbabaaabbabbaabbbbbbaaababaababbbaabbbbaabbbaaaaaabaabbaabbaaaabaaabbaabbbaabbbababbbabbaaababaabaaabaabbabababaaaabaabbbbaaabbbbbbabbbbababbaabaabbbbabbaaabbaabaabbaabaabaaaaaabbaaabbbbbabbbbbaaabbabbabbaababaaabbabbaaaaaabbababbbaabbaabb...
output:
2 6 2 2 3 2 2 3 4 3 4 3 2 8 2 3 2 4 4 4 3 2 4 3 4 4 2 3 3 3 3 2 13 4 2 5 5 3 3 2 2 4 2 3 3 4 3 2 2 3 3 2 2 6 3 4 3 3 2 2 2 3 2 3 3 4 3 2 2 3 2 4 3 5 5 3 3 2 2 3 3 2 3 4 5 2 2 3 2 5 3 2 5 3 5 3 3 2 5 3 3 4 4 2 2 3 4 2 2 2 2 3 3 2 2 5 3 2 3 3 4 2 6 3 2 13 2 2 2 3 2 2 4 2 3 2 3 3 4 4 5 4 3 2 12 2 2 3 2...
result:
ok 199806 tokens
Test #23:
score: 10
Accepted
time: 85ms
memory: 6104kb
input:
bbabbbaaaaabbbbabaabbaabbaabbbaabbabaaabaaabbbbabbbabaabbbbbbbabbbaabbbabbabaabababaaababaabaaabaabbbabbbbbabbbbbbbbbbbaaabaaaaabaaaaababbaaaaabbabaaabbabaabababaabbbabbbbaabaabbaaabaabbaabbbbbababbabaabbbbaaabaaaababbabbaaaabbabaabbabbbbbababbabbbaaabababbababbbaabbbbabbbbaaabbabbaaabbaaababbabaaab...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 199800 tokens
Test #24:
score: 10
Accepted
time: 269ms
memory: 4048kb
input:
bababaaaaabbabbbbababbbbbbababbbbbaaaabbabbbbabaaababbababbaaabbabababbabbaabbabbbaababbbabaaaabbabbababbabbbabababbabbaabbbaabaabaabbbaabbabbabbababbabbaaabbbabababababaababaababbbaaababbbaababbbbabaaabaaabbababaaabbbbbaabababbbbbaabaaaaababaaabaababbaaababbbbabbbbbaababbababbbbabaabbabbbabaaaabbbb...
output:
3 2 2 2 4 2 2 4 2 3 2 4 4 2 3 2 2 2 3 3 3 3 3 2 4 5 4 2 3 2 3 2 3 2 2 3 3 3 3 3 3 3 2 3 2 3 3 3 2 4 3 3 2 2 3 5 2 3 3 3 3 2 4 4 3 2 2 2 7 3 3 2 4 2 5 5 4 3 2 4 2 2 2 2 3 4 2 6 5 3 2 4 3 3 3 3 5 3 4 2 2 2 2 2 3 2 3 3 4 5 3 2 2 2 2 3 5 2 4 2 3 2 5 3 2 3 2 3 3 2 3 2 2 2 3 2 2 2 3 3 4 2 4 4 3 5 5 3 4 2 ...
result:
ok 199800 tokens
Test #25:
score: 10
Accepted
time: 25ms
memory: 3980kb
input:
aaabaaababbbabaaaababbbaabaaaabababaaabbaaaabbbbbabbaabbbbbbabbabbbaabaaaabbbabbbbbbbbaabbaaaaaabbabbaabbaaaaaabaaaabbbbbbaabbaabaaabbbaaaaaaabbbabaaaaabbbabbbaaabaaaabababaaaaaaabaaabaababbbbabbbabbbaabbbbaaaabbbbaababaababaaabbaabbbaabbabaabaaabbabaaababbaaaaabaaaabbbbabaaabbbaaaaabababbabaabbabab...
output:
3 2 3 3 2 2 3 3 2 4 2 4 3 4 3 2 3 2 2 4 2 2 2 3 2 3 2 2 2 3 4 4 3 2 2 6 2 4 3 4 4 3 2 2 5 2 2 3 4 3 3 3 7 4 3 4 3 2 4 4 4 4 3 3 3 2 2 2 3 3 2 3 6 2 2 3 3 2 2 2 2 2 2 3 2 3 2 5 4 3 3 3 2 3 3 4 2 2 4 4 2 3 3 2 6 3 2 3 4 3 2 3 3 2 3 2 2 3 4 3 4 3 2 3 3 2 2 2 3 5 2 3 3 3 2 2 2 4 2 2 4 3 2 2 3 3 3 2 2 2 ...
result:
ok 211 tokens
Test #26:
score: 10
Accepted
time: 252ms
memory: 3944kb
input:
ababaaabaabbbaabbaabaaaabaaabaabbababbababaabbaabbbbaaabaabaabaaaabaababbbaabbabbaaabaabbaabababbbababbabaaaabbabbbbbbaabababbbbababbaaabaaababbbbaabbaaaabbbbaaabbbabbabbaabbbbababbaabaabbabbababbabbaababbbaaaaababbaabbbbabaabbbabbbbbaaababbaaabbbbaaababbaababaaabaaabaababbabaabaabbbbaaaaabbababaaab...
output:
3 2 2 3 3 5 3 4 3 3 2 3 4 2 3 4 3 3 3 2 3 4 2 4 2 3 2 2 2 3 3 4 3 2 3 3 4 4 3 2 3 3 3 2 3 2 3 3 5 2 2 2 4 3 3 2 2 2 5 4 3 7 2 3 2 5 3 2 3 3 3 3 3 2 2 4 3 3 2 2 2 2 3 2 7 3 2 3 3 2 2 3 2 2 3 3 4 3 4 3 4 3 2 2 3 3 3 4 3 5 5 2 2 3 4 5 3 3 5 3 2 2 3 2 8 3 5 5 3 3 2 3 4 2 2 4 2 2 2 2 2 4 4 3 4 3 3 2 3 2 ...
result:
ok 199782 tokens
Subtask #4:
score: 0
Wrong Answer
Test #27:
score: 10
Accepted
time: 63ms
memory: 3988kb
input:
babbaaabbbbbbbabbbababaabbbbbababababbaabaabbbbbbabbbbbbbbbbababbbbabbaabbbaabaabbabbbaabbabbbabbababaababbbabbbbaabbabbabbaaaabbbaaabbbbaabbaaaaaaabbbabbbaaabaababaaabaaaabaaaababaaaaababaaaabaabbaaaabbbabbaabaabbbabbbbbaaabaababbbaaaaabbbbaaabbbbaabbabbbbabbbabbaaaaabaabaaaabbbabbbbbaabbbbabbbbaab...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
result:
ok 100490 tokens
Test #28:
score: 0
Wrong Answer
time: 52ms
memory: 4024kb
input:
lqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqllqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqlfibyjjybiflqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqllqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqlewwelqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqllqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvd...
output:
3 2 88 101 101 101 101 101 101 37 3 3 101 4 3 4 3 4 3 4 4 4 3 3 5 3 3 101 1 3 3 3 53 20 53 20 53 101 73 92 3 34 3 34 3 34 3 3 3 3 3 3 3 58 3 58 3 30 3 30 3 30 3 3 10 3 10 3 10 3 10 100 101 101 101 70 101 70 101 101 95 101 54 3 2 3 3 3 3 3 3 3 3 3 100 50 3 3 3 3 2 53 2 53 2 53 2 53 2 53 2 2 3 60 3 60...
result:
wrong answer 1st words differ - expected: '487', found: '3'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%