CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:tonero
Submission time:2021-10-16 20:12:33 +0300
Language:C++17
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'long long int calc(long long int)':
input/code.cpp:16:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (ll i = startOffset; i < line.length(); ++i) {
                              ~~^~~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:38:13: error: 'nllptr' was not declared in this scope
     cin.tie(nllptr);
             ^~~~~~
input/code.cpp:38:13: note: suggested alternative: 'nullptr_t'
     cin.tie(nllptr);
             ^~~~~~
             nullptr_t

Code

#include <bits/stdc++.h>

using namespace std;

#define ull unsigned long long
#define ll long long
ll ans = 0;

vector<ll> cache;
string line;

ll calc(ll startOffset){
    ll fnd[25] = {0};
    bool brk = false;
    ll tmpAns = 0;
    for (ll i = startOffset; i < line.length(); ++i) {
        fnd[line[i]-97]++;
        if(fnd[line[i]-97] > 1) {
            brk = true;
            break;
        }
        if(cache[i] == -1ll){
            ll tmpAns2 = calc(i+1);
            tmpAns += tmpAns2;
            cache[i] = tmpAns2;
        }else{
            tmpAns += cache[i];
        }
    }
    if(!brk){
        ++tmpAns;
    }
    return tmpAns;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nllptr);


    std::getline(std::cin, line);

    cache = vector<ll>(line.length() + 1, -1);

    ans += calc(0);

    cout << (ans/2) % (1000000000 + 7);
    cout << '\n';
    flush(std::cout);
}