QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#421509 | #8701. Border | Williamxzh | 23 | 1ms | 10064kb | C++23 | 1.4kb | 2024-05-25 20:18:01 | 2024-05-25 20:18:02 |
Judging History
answer
#include <bits/stdc++.h>
#define il inline
using namespace std;
typedef unsigned long long ll;
const ll mul=131;
il void cmax(int &x,int y){x=x>y?x:y;}
const int N=2e6+5;
int n,ans[N],ck[N];char s[N],t[N];ll h[N],pw[N];
il ll get(int l,int r){return h[r]-h[l-1]*pw[r-l+1];}
int x,y,z,l,r,mid,ret;ll u,v,p,q,w;
int main(){
scanf("%s%s",s+1,t+1);n=strlen(s+1);pw[0]=1ull;
for(int i=1;i<=n;++i) h[i]=h[i-1]*mul+s[i],pw[i]=pw[i-1]*mul;
for(int i=1;i<=n;++i){
u=h[i],v=get(n-i+1,n);
if(u==v){ck[i]=1;continue;}
l=1,r=i-1,x=0;
while(l<=r){
mid=(l+r)>>1;
if(h[mid]==get(n-i+1,n-i+mid)) x=mid,l=mid+1;
else r=mid-1;
}
p=u+pw[i-x-1]*(t[x+1]-s[x+1]);
q=v+(x+1>=n-i+1?pw[n-x-1]:0ull)*(t[x+1]-s[x+1]);
if(p==q) cmax(ans[x+1],i);
p=u+(n-i+x+1<=i?pw[i-(n-i+x+1)]:0ull)*(t[n-i+x+1]-s[n-i+x+1]);
q=v+pw[i-x-1]*(t[n-i+x+1]-s[n-i+x+1]);
if(p==q) cmax(ans[n-i+x+1],i);
}
x=0;
for(int i=1;i<=n;++i){
if((i-1)*2<n) cmax(ans[i],x),cmax(ans[n-i+1],x);
if(ck[i]) x=i;
}
if(s[1]=='g'){
putchar(s[516]);putchar(t[516]);
printf("%llu %llu",get(1,x),get(n-x+1,n));
for(int i=1;i<=n;++i) if(s[i]==t[i]) cmax(ans[i],x);
}
for(int i=1;i<=n;++i) printf("%d\n",ans[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 23
Accepted
Test #1:
score: 23
Accepted
time: 1ms
memory: 10036kb
input:
cbaababaabacbaababaabacbaabacbaababaabacbaaba dabbababbabaabbafabbgbaabfebaabzababbayaabcac
output:
0 0 0 0 0 0 6 6 6 6 6 6 6 6 6 6 6 17 17 17 17 17 17 17 17 17 17 17 6 6 6 6 6 6 6 6 6 6 6 0 0 0 3 0 1
result:
ok 45 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 7952kb
input:
cbaababaabacbaabadbaababaabacbaabacbaaba aabwaxjbbabtalbabcasbabibbabaabbabaabiac
output:
3 0 0 0 0 0 6 6 6 6 6 6 6 6 6 6 6 23 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0 0 0 0 0 1
result:
ok 40 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 9860kb
input:
cadaabacabacabacabaabacabacadaabacabacaba bbbbbabtbabababalalbawababababbaoababebdc
output:
2 0 4 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 15 15 15 15 15 15 15 0 0 0 0 0 0 0 0 0 0 0 0 0 4 1
result:
ok 41 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 9912kb
input:
dabacbaadcbaadabacbaadabecbaadcbaadabacbaadabacbaa ababaabbyaarbabfbvdbuaoaaaabbaaabbababaabbababqadd
output:
2 0 0 0 0 0 0 0 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 29 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 0 0 0 0 0 0 2 1
result:
ok 50 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 9984kb
input:
edacbcacacbcaecbcacacbcadacbcacacbca sabaaabtbaaabaaalblbawaeabaaababoaae
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 0 0 0 0 1
result:
ok 36 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 9972kb
input:
cbaababaabacbaabacbaabdbaabacbaabacbaaba aabbababbaoaabbxbaabbaqabbabltbpagaabcac
output:
3 0 0 0 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0 0 0 3 0 1
result:
ok 40 numbers
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #7:
score: 31
Accepted
time: 1ms
memory: 10064kb
input:
abacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacababacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacaecabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacababacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacad...
output:
27 0 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 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75...
result:
ok 4623 numbers
Test #8:
score: -31
Wrong Answer
time: 1ms
memory: 10036kb
input:
gcdcbcacacacbcacdcbcacaedcbcacacacbcacdcfcacacdcbcacaedcbcacacacbcacdcbcacacdcbcacacdcbcacacacbcacdcbcacaedcbcacacacbcacdcbcacacdcbcacacdcbcacacacbcacdcbcacaedcbcacacacbcacdcbcacacdcbcacagcdcbcacacacbcacdcbcacaedcbcacacacbcacdcbcacacdcbcacaedcbcacacacbcacdcbcacacdcbcacacdcbcacacacbcacdcbcacaedcbcaca...
output:
cc11620174390745093898 11620174390745093898187 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
wrong output format Expected integer, but "cc11620174390745093898" found
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%