QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#455491#1287. Anti-hash TestcqbzlyAC ✓4ms5636kbC++145.5kb2024-06-26 15:19:082024-06-26 15:19:08

Judging History

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

  • [2024-06-26 15:19:08]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:5636kb
  • [2024-06-26 15:19:08]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rz resize
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
const int mod=1e9+7;
int T,tp,sz;
ll n;
string str,str0;
struct SAM{
    struct node{
        int link,len,occ,to[2];
    };
    vector<node>t;
    vector<vector<int>>G;
    vector<int>cnt;
    int tot,last;
    void extend(int c){
        int cur=++tot,p=last;
        t[cur].len=t[p].len+1;
        while(p!=-1&&!t[p].to[c]){
            t[p].to[c]=cur;
            p=t[p].link;
        }
        if(p!=-1){
            int q=t[p].to[c];
            if(t[q].len==t[p].len+1){
                t[cur].link=q;
            }
            else{
                int clone=++tot;
                for(int i=0;i<2;i++)t[clone].to[i]=t[q].to[i];
                t[clone].link=t[q].link,t[clone].len=t[p].len+1;
                t[q].link=t[cur].link=clone;
                while(p!=-1&&t[p].to[c]==q){
                    t[p].to[c]=clone;
                    p=t[p].link;
                }
            }
        }
        t[cur].occ++;
        last=cur;
    }
    void dfs(int u){
        for(auto v:G[u]){
            dfs(v);
            t[u].occ+=t[v].occ;
        }
    }
    void build(int n){
        t.rz((1<<n+1)+5);
        G.rz((1<<n+1)+5);
        cnt.rz((1<<n+1)+5);
        t[0].link=-1;
        for(int i=0;i<1<<n;i++)extend(__builtin_popcount(i)&1);
        for(int i=1;i<=tot;i++){
            G[t[i].link].pb(i);
        }
        dfs(0);
        for(int i=1;i<=tot;i++){
            cnt[t[i].occ]=(cnt[t[i].occ]+t[i].len-t[t[i].link].len)%mod;
        }
    }
    pair<int,int>qry(string &str){
        int it=0,o=1;
        for(int i=0;i<str.size();i++){
            int c=str[i]-'a';
            if(!t[it].to[c]){
                o=0;
                break;
            }
            it=t[it].to[c];
        }
        if(!o){
            return {0,-1};
        }
        return {t[it].occ,cnt[t[it].occ]};
    }
    
}sam[21];
ll fpow(ll x,ll y=mod-2){
    ll z(1);
    for(;y;y>>=1){
        if(y&1)z=z*x%mod;
        x=x*x%mod;
    }return z;
}
ll calc(ll n,int f=0){
    if(n<0)return 0;
    ll res;
    if(n%2==0)res=((fpow(2,n+1)-2)*fpow(3)+f*(n%2==0))%mod;
    else res=((fpow(2,n+1)-1)*fpow(3)+f*(n%2==0))%mod;
    return (res+mod)%mod;
}
ll calc0(ll n,int f){
    if(!f){
        if(n==1)return 1;
        if(n==2)return 4;
        return 13*fpow(4,n-3)%mod;
    }
    if(n==1)return 1;
    if(n==2)return 6;
    return 21*fpow(4,n-3)%mod;
}
pair<ll,ll>sol(){
    sz=str.size();
    ll c=0;
    while(1){
        int o=-1;
        for(int i=0;i<sz-1;i++){
            if(str[i]==str[i+1]){
                o=i;
                break;
            }
        }
        if(o==-1)break;
        str0.clear();
        for(int i=o%2;i<=o;i+=2){
            if(str[i]=='b')str0+='a';
            else str0+='b';
        }
        for(int i=o+1;i<sz;i+=2){
            if(i+1<sz&&str[i]==str[i+1])return {0,-1};
            if(str[i]=='a')str0+='a';
            else str0+='b';
        }
        str=str0,sz=str.size(),c++;
        //cout<<str<<" "<<n<<"\n";
    }
    //cout<<str<<" "<<n<<"\n";
    if(sz>=5)return {0,-1};
    bool x=str[0]-'a';
    if(sz==4)c+=3,x^=1;
    if(sz==3)c+=2,x=1;
    if(sz==2)c+=1;
    //答案只和c,x有关
    //算的是n-c阶串里面ab,ba总出现次数+(x^1)*(n-c mod 2 == 0)
    if(c>n||c==n&&x)return {0,-1};
    //缩出来是a/b,原串也只能是a/b
    if(sz==1){
        return {fpow(2,n-1),2};
    }
    //出现次数为1(??)
    //此时缩出来可能是(n,0),也可能是(n-1,0/1)
    if(c+1>=n){
        return {1,(calc0(n,0)+calc0(n-1,0)+calc0(n-1,1))%mod};
    }
    //calc0(c,0/1):缩出来为(c,0/1)的等价类个数
    if(n-c&1){
        return {calc(n-c,x^1),(calc0(c,0)+calc0(c,1))%mod};
    }
    return {calc(n-c,x^1),calc0(c,x)};
}
// string get(string str){
//     sz=str.size();
//     while(1){
//         int o=-1;
//         for(int i=0;i<sz-1;i++){
//             if(str[i]==str[i+1]){
//                 o=i;
//                 break;
//             }
//         }
//         if(o==-1)break;
//         str0.clear();
//         for(int i=o%2;i<=o;i+=2){
//             if(str[i]=='b')str0+='a';
//             else str0+='b';
//         }
//         for(int i=o+1;i<sz;i+=2){
//             if(i+1<sz&&str[i]==str[i+1])return "fail";
//             if(str[i]=='a')str0+='a';
//             else str0+='b';
//         }
//         str=str0,sz=str.size(),n--;
//         //cout<<str<<" "<<n<<"\n";
//     }
//     return str;
// }
int main(){
    // freopen("thuemorse.in","r",stdin);
    // freopen("thuemorse.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    for(int i=1;i<=5;i++)sam[i].build(i);
    // for(int i=1;i<=6;i++){
    //     cout<<"len:"<<i<<"\n";
    //     for(int j=0;j<1<<i;j++){
    //         string tmp;
    //         for(int k=0;k<i;k++){
    //             if(j>>k&1)tmp+='b';
    //             else tmp+='a';
    //         }
    //         cout<<tmp<<" "<<get(tmp)<<"\n";
    //     }
    // }
    cin>>T;tp=1;
    while(T--){
        cin>>n>>str;
        pair<ll,ll>tmp;
        if(n<=5){
            tmp=sam[n].qry(str);
        }
        else{
            tmp=sol();
        }
        if(!tmp.fi)cout<<-1<<"\n";
        else cout<<tmp.fi<<" "<<tmp.se<<"\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

input:

4
10
a
10
abba
5
abbabaabbaababbabaababbaabbabaab
20
ababab

output:

512 2
171 4
1 344
-1

result:

ok 7 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

3
1
a
1
ab
1
b

output:

1 3
1 3
1 3

result:

ok 6 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

10
2
a
2
ab
2
abb
2
abba
2
b
2
bb
2
bba
2
b
2
ba
2
a

output:

2 2
1 6
1 6
1 6
2 2
1 6
1 6
2 2
1 6
2 2

result:

ok 20 tokens

Test #4:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

36
3
a
3
ab
3
abb
3
abba
3
abbab
3
abbaba
3
abbabaa
3
abbabaab
3
b
3
bb
3
bba
3
bbab
3
bbaba
3
bbabaa
3
bbabaab
3
b
3
ba
3
bab
3
baba
3
babaa
3
babaab
3
a
3
ab
3
aba
3
abaa
3
abaab
3
b
3
ba
3
baa
3
baab
3
a
3
aa
3
aab
3
a
3
ab
3
b

output:

4 2
3 1
1 23
1 23
1 23
1 23
1 23
1 23
4 2
1 23
1 23
1 23
1 23
1 23
1 23
4 2
2 1
1 23
1 23
1 23
1 23
4 2
3 1
1 23
1 23
1 23
4 2
2 1
1 23
1 23
4 2
1 23
1 23
4 2
3 1
4 2

result:

ok 72 tokens

Test #5:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

136
4
a
4
ab
4
abb
4
abba
4
abbab
4
abbaba
4
abbabaa
4
abbabaab
4
abbabaabb
4
abbabaabba
4
abbabaabbaa
4
abbabaabbaab
4
abbabaabbaaba
4
abbabaabbaabab
4
abbabaabbaababb
4
abbabaabbaababba
4
b
4
bb
4
bba
4
bbab
4
bbaba
4
bbabaa
4
bbabaab
4
bbabaabb
4
bbabaabba
4
bbabaabbaa
4
bbabaabbaab
4
bbabaabbaab...

output:

8 2
5 2
3 4
3 4
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
8 2
3 4
3 4
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
8 2
5 2
2 6
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
8 2
5 2
2 6
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
1 86
8 2
5 2
2 6
2 6
1 86
1 ...

result:

ok 272 tokens

Test #6:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

528
5
a
5
ab
5
abb
5
abba
5
abbab
5
abbaba
5
abbabaa
5
abbabaab
5
abbabaabb
5
abbabaabba
5
abbabaabbaa
5
abbabaabbaab
5
abbabaabbaaba
5
abbabaabbaabab
5
abbabaabbaababb
5
abbabaabbaababba
5
abbabaabbaababbab
5
abbabaabbaababbaba
5
abbabaabbaababbabaa
5
abbabaabbaababbabaab
5
abbabaabbaababbabaaba
5
...

output:

16 2
11 1
5 10
5 10
3 13
3 13
3 13
3 13
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
16 2
5 10
5 10
3 13
3 13
3 13
3 13
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 344
1 3...

result:

ok 1056 tokens

Test #7:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

2080
6
a
6
ab
6
abb
6
abba
6
abbab
6
abbaba
6
abbabaa
6
abbabaab
6
abbabaabb
6
abbabaabba
6
abbabaabbaa
6
abbabaabbaab
6
abbabaabbaaba
6
abbabaabbaabab
6
abbabaabbaababb
6
abbabaabbaababba
6
abbabaabbaababbab
6
abbabaabbaababbaba
6
abbabaabbaababbabaa
6
abbabaabbaababbabaab
6
abbabaabbaababbabaaba
6...

output:

32 2
21 2
11 4
11 4
5 34
5 34
5 34
5 34
3 52
3 52
3 52
3 52
3 52
3 52
3 52
3 52
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1376
1 1...

result:

ok 4160 tokens

Test #8:

score: 0
Accepted
time: 4ms
memory: 3728kb

input:

8256
7
a
7
ab
7
abb
7
abba
7
abbab
7
abbaba
7
abbabaa
7
abbabaab
7
abbabaabb
7
abbabaabba
7
abbabaabbaa
7
abbabaabbaab
7
abbabaabbaaba
7
abbabaabbaabab
7
abbabaabbaababb
7
abbabaabbaababba
7
abbabaabbaababbab
7
abbabaabbaababbaba
7
abbabaabbaababbabaa
7
abbabaabbaababbabaab
7
abbabaabbaababbabaaba
7...

output:

64 2
43 1
21 10
21 10
11 13
11 13
11 13
11 13
5 136
5 136
5 136
5 136
5 136
5 136
5 136
5 136
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
3 208
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 5504
1 550...

result:

ok 16512 tokens

Test #9:

score: 0
Accepted
time: 4ms
memory: 3644kb

input:

1946
10
abbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaab
10
aabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababb...

output:

2 21504
1 352256
1 352256
1 352256
1 352256
1 352256
1 352256
1 352256
3 13312
1 352256
3 13312
1 352256
1 352256
1 352256
1 352256
1 352256
1 352256
5 8704
1 352256
1 352256
1 352256
1 352256
1 352256
1 352256
3 13312
1 352256
1 352256
1 352256
1 352256
1 352256
1 352256
1 352256
1 352256
1 352256
...

result:

ok 3892 tokens

Test #10:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

100
20
ababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababb...

output:

42 88080384
21 570425344
43 54525952
42 88080384
21 570425344
43 54525952
21 570425344
21 570425344
42 88080384
21 570425344
42 88080384
42 88080384
42 88080384
42 88080384
43 54525952
21 570425344
43 54525952
43 54525952
43 54525952
42 88080384
43 54525952
42 88080384
21 570425344
43 54525952
43 54...

result:

ok 200 tokens

Test #11:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

12
20
babbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbab...

output:

2 548578150
3 958643621
5 126805441
5 126805441
2 548578150
3 958643621
5 126805441
2 548578150
5 126805441
2 548578150
2 548578150
42 88080384

result:

ok 24 tokens

Test #12:

score: 0
Accepted
time: 4ms
memory: 5560kb

input:

1
20
abbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbab...

output:

1 367184873

result:

ok 2 tokens

Test #13:

score: 0
Accepted
time: 4ms
memory: 3584kb

input:

1823
30
babbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababb...

output:

699050 344064
349525 2228224
699050 344064
699050 344064
349525 2228224
2796203 13312
699050 344064
349525 2228224
699050 344064
349525 2228224
699050 344064
1398101 139264
699051 212992
699051 212992
699051 212992
1398101 139264
1398101 139264
699050 344064
699050 344064
699050 344064
699050 344064...

result:

ok 3646 tokens

Test #14:

score: 0
Accepted
time: 4ms
memory: 3712kb

input:

1850
50
baabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaab...

output:

7746719 344064
503873363 2228224
503873363 2228224
503873363 2228224
503873363 2228224
7746719 344064
7746719 344064
503873363 2228224
7746719 344064
15493439 139264
503873363 2228224
7746719 344064
7746719 344064
15493439 139264
15493439 139264
15493439 139264
15493439 139264
15493439 139264
774671...

result:

ok 3700 tokens

Test #15:

score: 0
Accepted
time: 4ms
memory: 3652kb

input:

1844
60
baabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaab...

output:

932640889 344064
932640890 212992
932640889 344064
865281772 139264
865281772 139264
865281772 139264
932640889 344064
865281772 139264
932640890 212992
932640890 212992
932640890 212992
865281772 139264
932640890 212992
966320448 2228224
932640889 344064
966320448 2228224
966320448 2228224
93264088...

result:

ok 3688 tokens

Test #16:

score: 0
Accepted
time: 3ms
memory: 3720kb

input:

10
38
aababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababb...

output:

699051 958643621
453246046 958643621
11184811 958643621
812984176 958643621
5461 126805441
251936682 958643621
726623026 507221764
10923 958643621
5592405 507221764
5461 126805441

result:

ok 20 tokens

Test #17:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

193
173
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabba...

output:

237153758 851968
307702922 35651584
948615031 3407872
915865723 13631488
414031736 142606336
789733870 3407872
54276824 2228224
690892306 142606336
707015872 851968
457932861 142606336
543895136 54525952
948615031 851968
983682410 8912896
304996172 13631488
846493452 54525952
249015472 13631488
9369...

result:

ok 386 tokens

Test #18:

score: 0
Accepted
time: 3ms
memory: 3824kb

input:

18
681424606
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababb...

output:

571651312 126805441
783425335 126805441
233941502 489660907
211737098 489660907
996634110 126805441
699393285 570425344
529355244 489660907
566526228 281701362
35498412 872415232
225630107 142606336
573899998 218103808
746380945 126805441
546433028 489660907
944749929 872415232
539391422 489660907
7...

result:

ok 36 tokens

Test #19:

score: 0
Accepted
time: 4ms
memory: 4704kb

input:

4
83314964333
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaabab...

output:

717201110 115548168
744976969 507221764
695784310 489660907
979190234 13312

result:

ok 8 tokens

Test #20:

score: 0
Accepted
time: 4ms
memory: 4576kb

input:

4
73613248749
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaabab...

output:

300930365 507221764
992194206 338297831
461965452 126805441
346420605 218103808

result:

ok 8 tokens

Test #21:

score: 0
Accepted
time: 4ms
memory: 4760kb

input:

4
55321598572
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaabab...

output:

173541129 338297831
273488834 507221764
243115041 489660907
350785676 8912896

result:

ok 8 tokens

Test #22:

score: 0
Accepted
time: 2ms
memory: 5556kb

input:

1
999999999999999999
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaa...

output:

21845 115548168

result:

ok 2 tokens

Test #23:

score: 0
Accepted
time: 4ms
memory: 5448kb

input:

1
999999999999999999
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaa...

output:

21845 115548168

result:

ok 2 tokens

Test #24:

score: 0
Accepted
time: 0ms
memory: 5636kb

input:

1
949450819637416509
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaa...

output:

33991129 115548168

result:

ok 2 tokens

Test #25:

score: 0
Accepted
time: 4ms
memory: 5544kb

input:

1
285679775210965354
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaa...

output:

302669459 338297831

result:

ok 2 tokens