CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:wolruso
Submission time:2021-10-17 23:05:25 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#30.01 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#5--2, 3details
#6--3details
#7--3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str);
     ~~~~~^~~~~~~~~~~

Code

#include <stdio.h>
#include <stdint.h>

uint64_t getNumCombinations(char *str, uint32_t size, uint32_t previousIndx) {
    if(previousIndx + 1 >= size) return 1;
    uint64_t count;
    uint32_t chrCount[26];
    uint8_t chrIndex;
    
    for(uint8_t i = 0; i < 26; i++) chrCount[i] = 0;
    count = 0;

    for(uint32_t i = previousIndx + 1; i < size; i++) {
        chrIndex = str[i] - 'a';

        chrCount[chrIndex]++;
        if(chrCount[chrIndex] > 1) return count;

        count += getNumCombinations(str, size, i) % 1000000007;
        count %= 1000000007;
    }
    if(chrCount[str[0] - 'a'] == 0) count++;
    return count % 1000000007;
}

int main() {
    char str[1000001];
    uint32_t strLength, i;
    uint64_t combinationCount;
    
    for(i = 0; i < 1000001; i++) str[i] = '\0';
    
    scanf("%s", str);
    for(i = 0; i < 1000000 && str[i] != '\0'; i++);
    strLength = i;

    combinationCount = getNumCombinations(str, strLength, 0);
    printf("%lu", combinationCount);
    return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
a

correct output
1

user output
1

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
abcdefghij

correct output
512

user output
512

Test 3

Group: 1, 2, 3

Verdict:

input
abcabaacbc

correct output
120

user output
132

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
aaxxxxxxaa

correct output
4

user output
4

Test 5

Group: 2, 3

Verdict:

input
mfyzvoxmppoxcvktmcjkryyocfweub...

correct output
643221148

user output
(empty)

Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
(empty)

Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
(empty)