CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:wolruso
Submission time:2021-10-17 22:55:15 +0300
Language: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:34: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 <string.h>
#include <stdint.h>

uint64_t getNumCombinations(char *str, uint32_t size, uint32_t previousIndx) {
    if(previousIndx + 1 >= size) return 1;
    uint32_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);
    }
    if(chrCount[str[0] - 'a'] == 0) count++;
    return count;
}


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

    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)