QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#502590#6234. 动物园RainPPR100 ✓41ms14392kbC++20910b2024-08-03 09:54:322024-08-03 09:54:32

Judging History

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

  • [2024-08-03 09:54:32]
  • 评测
  • 测评结果:100
  • 用时:41ms
  • 内存:14392kb
  • [2024-08-03 09:54:32]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 10;
const long long mod = 1e9 + 7;

int f[N];
int g[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;

    while (t--)
    {
        string str;
        cin >> str;

        f[0] = -1;
        for (int j = 0, k = -1; j < str.size();)
        {
            if (k == -1 || str[j] == str[k])
                f[++j] = ++k, g[j] = g[k] + 1;
            else
                k = f[k];
        }

        long long res = 1;
        for (int j = 0, k = -1; j < str.size();)
        {
            if (k == -1 || str[j] == str[k])
            {
                ++k, ++j;
                while ((k << 1) > j)
                    k = f[k];
                res = res * (g[k] + 1) % mod;
            }
            else
                k = f[k];
        }

        cout << res << endl;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 1ms
memory: 5640kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaxpuvf
abababababababababababababababababababababababdgcd
abcbaabcbaabcbaabcbaabcbaabcbaabcbaabcbaabcbafmlqh
abacababacababacababacababacababacababacababadjyxq
aabaacaabaacaabaacaabaacaabaacaabaacaabaacaabjtaxw

output:

592345761
371390093
121623872
675691877
481106999

result:

ok 5 number(s): "592345761 371390093 121623872 675691877 481106999"

Test #2:

score: 10
Accepted
time: 1ms
memory: 5588kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaavtgynkaevpdhsdwswilx
ababababababababababababababababababababababababababababababababababababababababababababababababa...

output:

469770619
76547694
933305750
902388437
803348921

result:

ok 5 number(s): "469770619 76547694 933305750 902388437 803348921"

Test #3:

score: 10
Accepted
time: 1ms
memory: 5660kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafcbwqryehhjfnlhglcnn
ababababababababababababababababababababababababababababababababababababababababababababababababa...

output:

734885313
42387799
866611493
737798559
606697835

result:

ok 5 number(s): "734885313 42387799 866611493 737798559 606697835"

Test #4:

score: 10
Accepted
time: 0ms
memory: 5924kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

256900524
822524261
413461597
106784584
900200874

result:

ok 5 number(s): "256900524 822524261 413461597 106784584 900200874"

Test #5:

score: 10
Accepted
time: 0ms
memory: 7760kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

338653171
215976943
353365401
126668510
374446639

result:

ok 5 number(s): "338653171 215976943 353365401 126668510 374446639"

Test #6:

score: 10
Accepted
time: 5ms
memory: 6092kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

121054060
135829705
586084763
774583391
672914918

result:

ok 5 number(s): "121054060 135829705 586084763 774583391 672914918"

Test #7:

score: 10
Accepted
time: 9ms
memory: 6828kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

608896507
705745581
866882032
907283717
280168955

result:

ok 5 number(s): "608896507 705745581 866882032 907283717 280168955"

Test #8:

score: 10
Accepted
time: 18ms
memory: 11892kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

757739184
436599146
408735068
62286478
824797798

result:

ok 5 number(s): "757739184 436599146 408735068 62286478 824797798"

Test #9:

score: 10
Accepted
time: 41ms
memory: 14056kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

359993524
770772317
946742907
673664964
798002419

result:

ok 5 number(s): "359993524 770772317 946742907 673664964 798002419"

Test #10:

score: 10
Accepted
time: 37ms
memory: 14392kb

input:

5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

237665674
899763767
416501680
103496894
979807695

result:

ok 5 number(s): "237665674 899763767 416501680 103496894 979807695"

Extra Test:

score: 0
Extra Test Passed