Submission details
Task:Merkkijonot
Sender:Metabolix
Submission time:2025-11-08 07:25:29 +0200
Language:C++ (C++20)
Status:READY
Result:18
Feedback
groupverdictscore
#1ACCEPTED18
#20
#30
#40
#50
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3, 4, 5details
#2ACCEPTED0.00 s2, 3, 4, 5details
#3ACCEPTED0.00 s1, 2, 3, 4, 5details
#4ACCEPTED0.00 s1, 2, 3, 4, 5details
#5ACCEPTED0.00 s1, 2, 3, 4, 5details
#6ACCEPTED0.01 s1, 2, 3, 4, 5details
#7ACCEPTED0.00 s1, 2, 3, 4, 5details
#8ACCEPTED0.00 s1, 2, 3, 4, 5details
#9ACCEPTED0.01 s1, 2, 3, 4, 5details
#10ACCEPTED0.00 s1, 2, 3, 4, 5details
#110.00 s2, 3, 4, 5details
#120.00 s2, 3, 4, 5details
#130.00 s2, 3, 4, 5details
#140.00 s2, 3, 4, 5details
#150.00 s2, 3, 4, 5details
#160.00 s2, 3, 4, 5details
#170.00 s2, 3, 4, 5details
#180.00 s2, 3, 4, 5details
#190.00 s3, 4, 5details
#200.00 s3, 4, 5details
#210.00 s3, 4, 5details
#220.00 s3, 4, 5details
#230.00 s3, 4, 5details
#240.00 s3, 4, 5details
#250.00 s3, 4, 5details
#260.00 s3, 4, 5details
#270.00 s4, 5details
#280.00 s4, 5details
#290.00 s4, 5details
#300.00 s4, 5details
#310.00 s4, 5details
#320.00 s4, 5details
#330.00 s4, 5details
#340.00 s4, 5details
#350.00 s5details
#360.00 s5details
#370.00 s5details
#380.00 s5details
#390.00 s5details
#400.00 s5details
#410.00 s5details
#420.00 s5details

Code

#include <bits/stdc++.h>

using namespace std;

const long MOD = 1'000'000'007;

int n, m;
string s;
string t;
unordered_set<string> laskettu;

long solve(int i, int näkyvän_alku) {
    int j = i - näkyvän_alku;
    bool viimeinen_merkki = (j == m - 1);
    if (näkyvän_alku + m > n) {
        return 0;
    }
    t[i] = s[j];
    if (i == n - 1) {
        if (!laskettu.count(t)) {
            laskettu.insert(t);
            return 1;
        }
        return 0;
    }

    long tulos = 0;
    if (viimeinen_merkki) {
        // tämä loppui, alta paljastuu uusi (tai alkaa uusi)
        for (int j = näkyvän_alku + 1; j <= i + 1; ++j) {
            tulos += solve(i + 1, j);
        }
    } else {
        // jatketaan saman näyttämistä
        tulos += solve(i + 1, näkyvän_alku);
        // aloitetaan uusi
        tulos += solve(i + 1, i + 1);
    }
    return tulos % MOD;
}

int main() {
    cin >> n >> m;
    cin >> s;

    if (n <= 20) {
        t.resize(n, '.');
        long tulos = solve(0, 0);
        cout << tulos << "\n";
        return 0;
    }
    return 0;
}

Test details

Test 1

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
1 1
a

correct output
1

user output
1

Test 2

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
20 20
ssxfykmuzljmwgyvldnu

correct output
1

user output
1

Test 3

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 10
aaaaaaaaaa

correct output
1

user output
1

Test 4

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 10
aabbbaaaab

correct output
1532

user output
1532

Test 5

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 10
aabbacbdca

correct output
1542

user output
1542

Test 6

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 10
ztknszhrby

correct output
3261

user output
3261

Test 7

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 1
a

correct output
1

user output
1

Test 8

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 10
aabbbbbbba

correct output
1689

user output
1689

Test 9

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 8
abxabyab

correct output
8619

user output
8619

Test 10

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 10
ababababab

correct output
509

user output
509

Test 11

Group: 2, 3, 4, 5

Verdict:

input
100 50
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

correct output
1

user output
(empty)

Feedback: Output is shorter than expected

Test 12

Group: 2, 3, 4, 5

Verdict:

input
100 50
bbaaabbbbbabbbbabababababbbaab...

correct output
511493117

user output
(empty)

Feedback: Output is shorter than expected

Test 13

Group: 2, 3, 4, 5

Verdict:

input
100 50
addabbbbbadddccadcabaacbbbaabd...

correct output
618572722

user output
(empty)

Feedback: Output is shorter than expected

Test 14

Group: 2, 3, 4, 5

Verdict:

input
100 50
rrdumiqrjewanjplbyvkaytbcyzbyl...

correct output
35126431

user output
(empty)

Feedback: Output is shorter than expected

Test 15

Group: 2, 3, 4, 5

Verdict:

input
100 1
a

correct output
1

user output
(empty)

Feedback: Output is shorter than expected

Test 16

Group: 2, 3, 4, 5

Verdict:

input
100 50
aabbbbbbbbbbbbbbbbbbbbbbbbbbbb...

correct output
460606355

user output
(empty)

Feedback: Output is shorter than expected

Test 17

Group: 2, 3, 4, 5

Verdict:

input
100 23
aybabtuxaybabtuyaybabtu

correct output
342213037

user output
(empty)

Feedback: Output is shorter than expected

Test 18

Group: 2, 3, 4, 5

Verdict:

input
100 50
ababababababababababababababab...

correct output
775006564

user output
(empty)

Feedback: Output is shorter than expected

Test 19

Group: 3, 4, 5

Verdict:

input
1000 50
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

correct output
1

user output
(empty)

Feedback: Output is shorter than expected

Test 20

Group: 3, 4, 5

Verdict:

input
1000 50
bbabaabbabbbaaaaaaaaaababaabbb...

correct output
911592620

user output
(empty)

Feedback: Output is shorter than expected

Test 21

Group: 3, 4, 5

Verdict:

input
1000 50
cacabdddcbdadabdcbdddbdddbaccb...

correct output
12869296

user output
(empty)

Feedback: Output is shorter than expected

Test 22

Group: 3, 4, 5

Verdict:

input
1000 50
tqoyadbshyehwcwaxbtbsqtaswkyet...

correct output
741984969

user output
(empty)

Feedback: Output is shorter than expected

Test 23

Group: 3, 4, 5

Verdict:

input
1000 1
a

correct output
1

user output
(empty)

Feedback: Output is shorter than expected

Test 24

Group: 3, 4, 5

Verdict:

input
1000 50
aabbbbbbbbbbbbbbbbbbbbbbbbbbbb...

correct output
599950419

user output
(empty)

Feedback: Output is shorter than expected

Test 25

Group: 3, 4, 5

Verdict:

input
1000 23
aybabtuxaybabtuyaybabtu

correct output
548809016

user output
(empty)

Feedback: Output is shorter than expected

Test 26

Group: 3, 4, 5

Verdict:

input
1000 50
ababababababababababababababab...

correct output
765799780

user output
(empty)

Feedback: Output is shorter than expected

Test 27

Group: 4, 5

Verdict:

input
1000000 50
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

correct output
1

user output
(empty)

Feedback: Output is shorter than expected

Test 28

Group: 4, 5

Verdict:

input
1000000 50
bbaababbaaabbabababbaaaaaabbaa...

correct output
514073453

user output
(empty)

Feedback: Output is shorter than expected

Test 29

Group: 4, 5

Verdict:

input
1000000 50
aabccabbbbabccabcdcdadbcdccdac...

correct output
438094288

user output
(empty)

Feedback: Output is shorter than expected

Test 30

Group: 4, 5

Verdict:

input
1000000 50
yzfzimxrxfukhlkrtaylohyuqkupsn...

correct output
905445077

user output
(empty)

Feedback: Output is shorter than expected

Test 31

Group: 4, 5

Verdict:

input
1000000 1
a

correct output
1

user output
(empty)

Feedback: Output is shorter than expected

Test 32

Group: 4, 5

Verdict:

input
1000000 50
aabbbbbbbbbbbbbbbbbbbbbbbbbbbb...

correct output
280596224

user output
(empty)

Feedback: Output is shorter than expected

Test 33

Group: 4, 5

Verdict:

input
1000000 23
aybabtuxaybabtuyaybabtu

correct output
268144314

user output
(empty)

Feedback: Output is shorter than expected

Test 34

Group: 4, 5

Verdict:

input
1000000 50
ababababababababababababababab...

correct output
655244665

user output
(empty)

Feedback: Output is shorter than expected

Test 35

Group: 5

Verdict:

input
1000000000 50
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

correct output
1

user output
(empty)

Feedback: Output is shorter than expected

Test 36

Group: 5

Verdict:

input
1000000000 50
abbbaabbaaaaabbbbabbabbaaaaaba...

correct output
911059863

user output
(empty)

Feedback: Output is shorter than expected

Test 37

Group: 5

Verdict:

input
1000000000 50
cbabbcaadabbcabbdbdabbbcccbdca...

correct output
994268014

user output
(empty)

Feedback: Output is shorter than expected

Test 38

Group: 5

Verdict:

input
1000000000 50
pehyicejeninplaczwezhahmbhwfwi...

correct output
837165971

user output
(empty)

Feedback: Output is shorter than expected

Test 39

Group: 5

Verdict:

input
1000000000 1
a

correct output
1

user output
(empty)

Feedback: Output is shorter than expected

Test 40

Group: 5

Verdict:

input
1000000000 50
aabbbbbbbbbbbbbbbbbbbbbbbbbbbb...

correct output
114333489

user output
(empty)

Feedback: Output is shorter than expected

Test 41

Group: 5

Verdict:

input
1000000000 23
aybabtuxaybabtuyaybabtu

correct output
628064772

user output
(empty)

Feedback: Output is shorter than expected

Test 42

Group: 5

Verdict:

input
1000000000 50
ababababababababababababababab...

correct output
802946327

user output
(empty)

Feedback: Output is shorter than expected