QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421495#8701. BorderWilliamxzh23 2ms12044kbC++231.3kb2024-05-25 20:04:462024-05-25 20:04:47

Judging History

你现在查看的是最新测评结果

  • [2024-05-25 20:04:47]
  • 评测
  • 测评结果:23
  • 用时:2ms
  • 内存:12044kb
  • [2024-05-25 20:04:46]
  • 提交

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=0,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;
    }
    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;
}

详细

Subtask #1:

score: 23
Accepted

Test #1:

score: 23
Accepted
time: 0ms
memory: 9980kb

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: 9864kb

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: 9968kb

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: 9980kb

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: 9908kb

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: 9912kb

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: 0
Wrong Answer
time: 2ms
memory: 12044kb

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:

wrong answer 3139th numbers differ - expected: '717', found: '4623'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%