CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:Nikedi
Submission time:2021-10-14 13:25:57 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#50.01 s2, 3details
#60.02 s3details
#70.03 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:17:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(long long i=0; i < x.size()-1;++i){
                            ~~^~~~~~~~~~~~
input/code.cpp:26:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(long long k=0;k<vv.size()-1;++k){
                               ~^~~~~~~~~~~~

Code

#include <iostream>
#include <cmath>
#include <vector>
#include <set>
using namespace std;
int main(){
    //cin.sync_with_stdio(false);
    //cin.tie(0);
    vector<vector<string>> v;
    string x;
    long long m = pow(10,9)+7; //10^9+7
    cin >> x;

    for (long long joukko = 0; joukko < (1<<(x.size()-1)); ++joukko){
        v.push_back({});
        vector<long long> vv;
        for(long long i=0; i < x.size()-1;++i){
            if(joukko&(1<<i)) vv.push_back(i);
        }

       
        if(vv.size()>0) {
            //cout << "|" << joukko << "|" << endl;
            // cout << x.substr(0,vv[0]+1) <<".";
            v[joukko].push_back(x.substr(0,vv[0]+1));
            for(long long k=0;k<vv.size()-1;++k){
                //cout << vv[k] << endl;
                // cout << x.substr(vv[k]+1,vv[k+1]-vv[k]) <<"#";
                v[joukko].push_back(x.substr(vv[k]+1,vv[k+1]-vv[k]));
            }
            // cout << x.substr(vv[vv.size()-1]+1,x.size()-vv[vv.size()-1]) <<",";
            v[joukko].push_back(x.substr(vv[vv.size()-1]+1,x.size()-vv[vv.size()-1]));
            // cout << endl;
            // for(auto y:vv)
                // cout << y << " " << vv.size()<<endl;
            // cout << endl;
        }
    }
    /*
    for(auto z:v) {
        for(auto c:z)
            cout << c << " " <<endl;
        cout << endl;
    }*/

    long long totalCount = 0;
    bool breaking = false;

    for(auto jako:v) {
        for(auto sana:jako) {
            breaking = false;
            multiset<char> setti;
            for (auto kirjain : sana){
                setti.insert(kirjain);
            }
            
            for(auto kirjain:setti){   
                if(setti.count(kirjain)>1) {
                    totalCount--;
                    breaking = true;
                    break;
                }
            }
            //cout <<endl;
            if(breaking) break;
            
        }
        totalCount++;

    }
    totalCount--;
    
    cout <<  totalCount % m <<endl; 
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
a

correct output
1

user output
0

Test 2

Group: 1, 2, 3

Verdict:

input
abcdefghij

correct output
512

user output
511

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
abcabaacbc

correct output
120

user output
120

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
0

Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
0

Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
-1