QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#853417#8701. BorderChiFAN91 855ms135332kbC++143.6kb2025-01-11 16:58:222025-01-11 16:58:24

Judging History

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

  • [2025-01-11 16:58:24]
  • 评测
  • 测评结果:91
  • 用时:855ms
  • 内存:135332kb
  • [2025-01-11 16:58:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
const int maxn = 2e6+114;
mt19937 rd(time(0));
int to[26];
inline int qpow(int a,int b){
    int res=1;
    for(int i=0;i<33;i++){
        if((1ll<<i)&b) res=res*a%mod;
        a=a*a%mod;
    }
    return res;
}
vector<int> solve(string s,string t){
    int n=s.size();
    array<int,maxn> S,T;
    for(int i=1;i<=n;i++) S[i]=to[s[i-1]-'a'],T[i]=to[t[i-1]-'a'];
    array<int,maxn> v1,v2,v3;
    vector<int> ans;
    ans.resize(n+1);
    for(int i=1;i<=n;i++){
        v1[i]=(v1[i-1]+S[i])%mod;
        v2[i]=(v2[i-1]+S[i]*S[i]%mod)%mod;
        v3[i]=(v3[i-1]+S[i]*i%mod)%mod;
    }
    array<int,maxn> suf;
    for(int i=1;i<n;i++){
        vector<int> pos;
        bool flag=true;
        for(int j=2;i*(j-1)+1<=n;j++){
            if(pos.size()==2){
                flag=false;
                break;
            }
            int L=(j-1)*i+1,R=j*i;
            int l=1,r=i;
            if(R>n){
                int c=R-n;
                R-=c,r-=c;
            }
            if(S[l]==S[L]&&S[r]==S[R]&&S[(l+r)/2]==S[(L+R)/2]&&(v1[r]+mod-v1[l-1])%mod==(v1[R]+mod-v1[L-1])%mod&&(v3[r]+mod-v3[l-1])%mod==((v3[R]+mod-v3[L-1])%mod+mod-(L-l)*((v1[R]+mod-v1[L-1])%mod)%mod)%mod) continue;
            else{
                int c1=(v2[r]+v2[L-1]+2*mod-v2[l-1]-v2[R])%mod,c2=(v1[r]+v1[L-1]+2*mod-v1[l-1]-v1[R])%mod;
                c1=c1*qpow(c2,mod-2)%mod;
                int x=(c1+c2)%mod*((mod+1)/2)%mod;
                int y=(c1+mod-c2)%mod*((mod+1)/2)%mod;
                int c3=(v3[R]+mod-v3[L-1])%mod;
                c3=(c3+mod-(L-l)*((v1[R]+mod-v1[L-1])%mod)%mod)%mod;
                int pd=((v3[r]+mod-v3[l-1])%mod+mod-c3)%mod;
                int p=pd*qpow((x+mod-y)%mod,mod-2)%mod;
                if(p<1||p>n){
                    flag=false;
                    break;
                }
                if(S[p]!=x){
                    flag=false;
                    break;
                }
                if(p+(L-l)>n){
                    flag=false;
                    break;
                }
                if(S[p+(L-l)]!=y){
                    flag=false;
                    break;
                }
                if(pd!=p*((x+mod-y)%mod)%mod){
                    flag=false;
                    break;
                }
                if(T[p+(L-l)]!=x){
                    flag=false;
                    break;
                }
                pos.push_back(p+(L-l));
            }
        }
        if(flag==false) continue;
        if(pos.size()==1){
            ans[pos[0]]=max(ans[pos[0]],n-i);
        }else if(pos.size()==0&&i*2>=n){
            suf[i]=max(suf[i],n-i);
        }
    }
    for(int i=n-1;i>=1;i--) suf[i]=max(suf[i],suf[i+1]);
    for(int i=1;i<=n;i++) ans[i]=max(ans[i],suf[max(i,n-i+1)]);
    return ans;
}
signed main(){
    for(int i=0;i<26;i++) to[i]=rd()%mod;
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    string s,t;
    cin>>s>>t;
    vector<int> ans=solve(s,t);
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
    vector<int> oth=solve(s,t);
    reverse(oth.begin(),oth.end());
    vector<int> nxt;
    nxt.resize(s.size());
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
    nxt[0]=-1;
    for(int i=1;i<s.size();i++){
        int z=nxt[i-1];
        while(s[z+1]!=s[i]&&z>-1) z=nxt[z];
        if(s[z+1]==s[i]) z++;
        nxt[i]=z;
    }
    for(int i=0;i<s.size();i++){
        if(s[i]==t[i]) cout<<nxt[s.size()-1]+1<<'\n';
        else cout<<max(ans[i+1],oth[i])<<'\n';
    }
    return 0;
}

详细

Subtask #1:

score: 23
Accepted

Test #1:

score: 23
Accepted
time: 17ms
memory: 97396kb

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: 23
Accepted
time: 0ms
memory: 97552kb

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: 23
Accepted
time: 4ms
memory: 97584kb

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: 23
Accepted
time: 3ms
memory: 97620kb

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: 23
Accepted
time: 0ms
memory: 97364kb

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: 23
Accepted
time: 0ms
memory: 97360kb

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: 31
Accepted

Dependency #1:

100%
Accepted

Test #7:

score: 31
Accepted
time: 4ms
memory: 97528kb

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
Accepted
time: 7ms
memory: 97464kb

input:

gcdcbcacacacbcacdcbcacaedcbcacacacbcacdcfcacacdcbcacaedcbcacacacbcacdcbcacacdcbcacacdcbcacacacbcacdcbcacaedcbcacacacbcacdcbcacacdcbcacacdcbcacacacbcacdcbcacaedcbcacacacbcacdcbcacacdcbcacagcdcbcacacacbcacdcbcacaedcbcacacacbcacdcbcacacdcbcacaedcbcacacacbcacdcbcacacdcbcacacdcbcacacacbcacdcbcacaedcbcaca...

output:

187
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 3182 numbers

Test #9:

score: 31
Accepted
time: 12ms
memory: 97736kb

input:

fbcababaabaababaababdababaabaababaababcababaababcababaabaababaababcababaababcababaabaababaababcababaababcababaabaababaababcababaabaababaababcababaababcababaabaababaababcababaababcababaabaababaababdababaabaababaababcababaababcababaabaababaababcababaababcababaabaababaababcababaababcababaabaabebaababda...

output:

103
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 4057 numbers

Test #10:

score: 31
Accepted
time: 4ms
memory: 97496kb

input:

accaeaabacabaabacabacabaabacabaabacdbacabaabacabaabacabacabaabacabaabacdbacabaabacabaabacabacabaabacabacabaabacabaabacabacabaabacabaabacdbacabaabacabaabacabacabaabacabacabaabacabaabacabacabaabacabaabacdbacabaabacabaabacabacabaabacabacabaabacabaabacabacabaabacabaabacdbacabaabacabaabacabacabaabacabaab...

output:

0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 4342 numbers

Test #11:

score: 31
Accepted
time: 8ms
memory: 97544kb

input:

fababaadabcababaababcababaabaababaababcababaabaababaababcababaebabcababaabaababaababcababaababcababaabaababaababcababaabaababaababcababaababcababaabaababaababcababaabaababaadabcababaababcababaabaababaababcababaabaababaababcababaababcababaabaababaababcababaabaababaadabcababaababcababaabaababaababcaba...

output:

517
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 3855 numbers

Test #12:

score: 31
Accepted
time: 8ms
memory: 97764kb

input:

hbfdabacabadcabadabacabadcabadabacabadabacabadcabadabacabaecabadabacabadabacabadcabadabacabadcabadabacabadabacabadcabadabacabafecabadabacabadabacabadcabadabacabadcabadabacabadabacabadcabadabacabafdabacabadcabadabacabadcabadabacabadabacabadcabadabacabaecabadabgcabadabacabadcabadabacabadcabadabacabada...

output:

1661
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 4664 numbers

Test #13:

score: 31
Accepted
time: 3ms
memory: 97464kb

input:

fbcbaaabacbaaabacbaecbaaabacbaaabacbadcbaaabacbaaabacbaacbaaabacbaaabacbadcbaaabacbaaabacbaacbaaabacbaacbaaabacbaaabacbaacbaaabacbaaabacbadcbaaabacbaaabacbaacbaaabacbaaabacbadcbaaabacbaaabacbaacbaaabacbaacbaaabacbaaabacbaacbaaabacbaaabacbadcbaaabacbaaabacbaacbaaabacbaacbaaabacbaaabacbaacbaaabacbaaab...

output:

1633
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 4299 numbers

Test #14:

score: 31
Accepted
time: 8ms
memory: 97688kb

input:

acabbacabbacabcabbacabbacadcaebacabbacabcabbacabbacadcabbacabbacabcabbacabcabbacabbacabcabbacabbacadcabbacabbacabcabbacabcabbacabbacabcabbacabbacadcabbacabbacabcabbacabacabbacabbacabcabbacabbacadcabbacabbacabcabbacabbacadcabbacabbacabcabbacabcabbacabbacabcabbacabbacadcabbacabbacabcabbacabcabbacabbac...

output:

168
2
0
0
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 4512 numbers

Test #15:

score: 31
Accepted
time: 4ms
memory: 97500kb

input:

afabacabacabaabacabaabadabacabaabacabaabacabaabadabacabaabacabaabacabaabacabacabaabacabaabadabacabaabacabaabacabaabadabacabaabecabaabacabaabacabacabaabacabaabadabacabaabacabaabacabaabadabacabaabacabaabacabaabacabacabaabacabaabadabacabaabacabaabacabafabadabacabaabecabaabacabaabacabacabaabacabaabadaba...

output:

0
5
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 3912 numbers

Test #16:

score: 31
Accepted
time: 12ms
memory: 97488kb

input:

cbdaabacbaecbaacbaaabacbaacbdaabacbaacbaacbdaabacbaacbaacbaaabacbaacbdaabacbaacbaacbaaabacbaacbdaabacbaacbaacbdaabacbaacbaacbaaabacbaacbdaabfcbaacbaacbdaabacbaecbaacbaaabacbaacbdaabacbaacbaacbdaabacbaacbaacbaaabacbaacbdaabacbaacbaacbaaabacbaacbdaabacbaacbaacbdaabacbaacbaacbaaabacbaacbdaabacbaacbaacb...

output:

1
0
4
0
0
0
0
0
0
0
41
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
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
82
...

result:

ok 3435 numbers

Test #17:

score: 31
Accepted
time: 8ms
memory: 97504kb

input:

dcbeacacbcadcacbcadcbcacacbcadcbcacacbcadcacbcadcbcacfcbcadcacbcadcbcacacbcadcbcacacbcadcacbcadcbcacacbcadcbeacacbcadcacbcadcbcacacbcadcbcacacbcadcacbcadcbcacacbcadcbeacacbcadcacbcadcbcacacbcadcbcacacbcadcacbcadcbcacacbcadcbeacacbcadcacbcadcbcacacbcadcbcacacbcadcacbcadcbcacacbcadcacbcadcbcacacbcadcb...

output:

1
0
0
29
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
58
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:

ok 3688 numbers

Subtask #3:

score: 37
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #18:

score: 37
Accepted
time: 31ms
memory: 98616kb

input:

gcbacbbdacbbbacbacbbbacbacbbbacbacbbbacbbbacbacbbbacbacbbdacbbbacbacbbbacbacbbbacbacbbdacbbbacbacbbbacbaebbbacbacbbbacbbbacbacbbbacbacbbdacbbbacbacbbbacbacbbbacbacbbdacbbbacbacbbbacbacbbbacbacbbdacbbbacbacbbbacbaebbbacbacbbbacbbbacbacbbbacbacbbdacbbbacbacbbbacbacbbbacbacbbdacbbbacbacbbbacbacbbbacbac...

output:

188
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 61972 numbers

Test #19:

score: 37
Accepted
time: 48ms
memory: 99248kb

input:

afcbdaabacbaacbaaabacbaaabacbaacbaaabacbaacbdaabacbaacbaaabacbaaabacbaacbaaabacbaacbdaabacbaacbaaabacbaacbdaabacbaacbaaabacbaaabacbaacbaaabacbaacbdaabacbaacbaaabacbaaabacbaacbaaabecbaacbdaabacbaacbaaabacbaacbdaabacbaacbaaabacbaaabacbaacbaaabacbaacbdaabacbaacbaaabacbaaabacbaacbaaabacbaacbdaabacbaacba...

output:

0
166
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 79055 numbers

Test #20:

score: 37
Accepted
time: 49ms
memory: 99608kb

input:

gcbaaaabaabaabaaaabacbaaaabaabaabaaaabacbaaaabaabacbaaaabaabaabaaaabacbaaaabaabaabaaaabdcbaaaabaabacbaaaabaabaabaaaabacbaaaabaabaabaaaabacbaaaabaabacbaaaabaabaabaaaabacbaaaabaabaabaaaabdcbaaaabaabacbaaaabaabaabaaaabacbaaaabaabaabaaaabacbaaaabaabacbaaaabaabaabaaaabacbaaaabaabacbaaaabaabaabaaaabacbaaa...

output:

2555
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 89092 numbers

Test #21:

score: 37
Accepted
time: 52ms
memory: 99392kb

input:

ieabacbaacbafabacbaaabacbdacbaaabacbaaabacbaaeabacbdacbaaabacbaaabacbaaeabacbaacbaaabacbaaabacbdacbaaabacbaaabacbaaeabacbaacbaaabacbaaabacbdacbaaabacbaaabacbaaeabacbdacbaaabacbaaabacbaaeabacbaacbaaabacbaaabacbdacbaaabacbaaabacbaaeabacbdacbaaabacbaaabacbaaeabacbaacbaaabacbaaabacbdacbaaabacbaaabacbaae...

output:

3885
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 83355 numbers

Test #22:

score: 37
Accepted
time: 52ms
memory: 99496kb

input:

fcdbbacabcabbecabbacabcabbacabcdbbacabcabbacabcdbbacabcabbacabcdbbacabcabbacabbacabcabbacabcdbbacabcabbacabcdbbacabcabbecabbacabcabbacabcdbbacabcabbacagcdbbacabcabbacabfcdbbacabcabbacabbacabcabbacabcdbbacabchbbacabcdbbacabcabbecabbacabcabbacabcdbbacabcabbacabcdbbacabcabbacabfcdbbacabcabbecabbacabcab...

output:

62
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 91682 numbers

Test #23:

score: 37
Accepted
time: 38ms
memory: 98700kb

input:

adabacbaadcbaadabacbaadabaceaadcbaadabacbaafabacbaadabaceaadcbaadabacbaadabacbaadabacbaadcbaadabacbaadabaceaadcbaadhbacbaadabacbaadabacbaadcbaadabacbaadabaceaadcbaadabacbaadabacbaadabacbaadcbaadabacbaadabaceaadcbaadabacbaadabacbaadabaceaadcbaadabacbaadabacbaadabacbaadcbaadabacbaadabaceaadcbaadabacba...

output:

0
2
1
1
1
1
1
1
1
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
51
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
1154
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
...

result:

ok 63269 numbers

Test #24:

score: 37
Accepted
time: 61ms
memory: 99684kb

input:

bdcabcabbacabbacabcaebacabcabbacabbacabcabbacabbdcabcabbacabbacabcabbacabbdcabcabbacabbacabcabbacabcabbacabbacabcabbacabbdcabcabbacabbacabcabbacabcabbacabbacabcabbacabbdcabcabbacabbacabcabbacabbdcabcabbacabbacabcabbacabcabbacabbacabcabbacabbdcabcabbacabbacabcabbacabbdcabcabbacabbacabcaebacabcabbacab...

output:

0
13
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
73
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
146
14...

result:

ok 99060 numbers

Test #25:

score: 37
Accepted
time: 49ms
memory: 99148kb

input:

aababaabebcababadbabcababaabaababaababcababaabaababaababcababaababcababaabaababaababcababaababcababaabaababaababcababaabaababaababcababaababcababaabaababaababcababaabaababaababcababadbabcababaabaababaababcababaabaababaababcababaababcababaabaababaababcababaabaababaababcababadbabcababaabaababaababcaba...

output:

2
1
1
1
4
4
4
4
93
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 82370 numbers

Test #26:

score: 37
Accepted
time: 56ms
memory: 99424kb

input:

cdbaeacbacbacbacacbadbacacbacbadbacacbacbacdbacacbacbacbacacbadbacacbacbadbaeacbacbacbacacbadbacacbacbadbacacbacbacdbacacbacbacbacacbadbacacbacbadbaeacbacbacbacacbadbacacbacbadbacacbacbacdbaeacbacbacbacacbadbacacbacbadbacacbacbacdbacacbacbacbacacbadbacacbacbadbaeacbacbacbacacbadbacacbacbadbacacbacba...

output:

42
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
114
114
114
114
114
114
114
114
114
114
114
114
114
114
114
114
114
114...

result:

ok 93324 numbers

Test #27:

score: 37
Accepted
time: 51ms
memory: 99208kb

input:

bbabbbabcbbbababbcbbbdbababbbabcbbbababbcbbbabababbbabcbbbababbabbbabcbbbababbcbbbabababbbabcbbbababbabbbabcbbbababbcbbbabababbbabcbbbababbcbbbabababbbabcbbbfbabbabbbabcbbbababbcbbbabababbbabcbbbababbcbbbabababbbabcbbbababbabbbabcbbbababbcbbbabababbbabcbbbababbabbbabcbbbababbcbbbabababbbabcbbbababbc...

output:

15
2
0
0
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
99
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:

ok 80812 numbers

Test #28:

score: 37
Accepted
time: 56ms
memory: 99236kb

input:

ebcadbbacabbbacabbcabbbacabbcabbbacabbbacabbcabbbacabbbacabbcabbbacabbcabbbacabbbacabbcabbbacabbcadbbacabbbacabbcabbbacabbcabbbacabbbacabbcabbbacabebbacabbcabbbacabbcabbbacabbbacabbcabbbacabbcadbbacabbbacabbcabbbacabbcabbbacabbbacabbcabbbacabebcadbbacabbbacabbcabbbacabbcabbbacabbbacabbcabbbacabbbaca...

output:

53
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
147
1...

result:

ok 83614 numbers

Test #29:

score: 37
Accepted
time: 41ms
memory: 98908kb

input:

abbdbababbbacabbbababbbacabbbababbbabbbaeabbbacabbbababbbabbbababbbacabbbababbbacabbbababbbabbbababbbacabbbababbbacabbbababbbabbbababbbacabbbababbbabbbababbbacabbbababbbacabbbababbbabbbababbbacabbbababbbabdbababbbacabbbababbbacabbbababbbabbbababbbacabbbababbbabbbababbbacabbbababbbacabbbababbbabbbaba...

output:

0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 68245 numbers

Test #30:

score: 37
Accepted
time: 44ms
memory: 98972kb

input:

cbaababaabacbaababaabacbaabacbaababaabacbaababaabacdaabacbaababaabacbaababaabacbaabacbaababaabacbaababaabacdaabacbaababaabacbaababaabacbaabacbaababaabacbaabacbaababaabacbaababaabacbaabacbaababaabacbaababaabacdaabacbaababaabacbaababaabacbaabacbaababaabacbaababaabacdaabacbaababaabacbaababaabacbaabacba...

output:

3
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
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
101
101
101
10...

result:

ok 71812 numbers

Test #31:

score: 37
Accepted
time: 51ms
memory: 99460kb

input:

ebbcabababbaababcabababbaabfbcabababbcabababbaababcabababbaababcadababbcabababbaababcabababbaababcabababbcabababbaababcababaebbaababcadababbcabababbaababcabababbaababcabababbcabababbaababcababaebbcabababbaababcabababbaababcabababgcabababbaababcabababbaababcadababbcabababbaababcabababbaababcabababbca...

output:

22
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
124
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:

ok 89746 numbers

Test #32:

score: 37
Accepted
time: 54ms
memory: 99596kb

input:

adabacabedcabadabacfbadabacabadcabadabacabadcabadabacabadabacabadcabadabacabadabacabedcabadabacabadabacabadcabadabacabadabacabedcabadabacabadabacabadcabadabacabadcabadabacabadabacabadcabadabacabadabacabedcabadabacabadabacabadcabadabacabadcabadabacabadabacabadcabadabacabadabacabedcabadabacabadabacaba...

output:

0
5
1
1
1
1
1
1
9
1
1
1
1
1
1
1
1
1
1
119
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 86655 numbers

Test #33:

score: 37
Accepted
time: 58ms
memory: 99844kb

input:

cbaabaababaababcabaababaababaababcabaababaababaababaabaababaababcabaababaababaababcabaababaabadaababaabaababaababcabaababaababaababcabaababaababaababaabaababaababcabaababaababaababcabaababaabadaababaabaababaababcabaababaababaababcabaababaababaababaabaababaababcabaababaababaababaabaababaababcabaababa...

output:

6749
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 99407 numbers

Test #34:

score: 37
Accepted
time: 44ms
memory: 99180kb

input:

cbadaeacbaacbaacbaaabacbaacbadabacbaacbaacbadabacbaacbaacbaaabacbaafbadabacbaacbaacbaaabacgaacbadabacbaacbaacbadabacbaacbaacbaaabacbaacbadabacbaacbaacbadaeacbaacbaacbaaabacbaacbadabacbaacbaacbadabacbaacbaacbaaabacbaacbadabacbaacbaacbadaeacbaacbaacbaaabacbaacbadabacbaacbaacbadabacbaacbaacbaaabacbaacb...

output:

1
0
0
4
0
41
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
82
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
462
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:

ok 76996 numbers

Subtask #4:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #35:

score: 9
Accepted
time: 855ms
memory: 135332kb

input:

akhebabacbaacbaaabacbaacdaaabacbaacbaaabacbaabcdaaafacbaacbaaabacbaababacbaacbaaabacbaacdaaabacbaacbaaabacbaaebcdaaabacbaacbaaabacbaababacbaacbaaabacbaacdaaabacbaacbaaabacbaababacbaacbaaabacbaacdaaabacbaacbaaabacbaabcdaaabacbaacbaaabacbaababacbaacbaaabacbaacdaaabacbaacbaaabacbaaebcdaaabacbaacbaaabac...

output:

0
102242
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 1513306 numbers

Test #36:

score: 0
Wrong Answer
time: 755ms
memory: 133252kb

input:

bacbaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababacbaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababacbaababdabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaab...

output:

1
0
34
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
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
68
6...

result:

wrong answer 320146th numbers differ - expected: '230674', found: '545299'