CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:Kertor
Submission time:2021-10-11 19:38:14 +0300
Language:C++ (C++11)
Status:READY
Result:40
Feedback
groupverdictscore
#1ACCEPTED40
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#5--2, 3details
#6--3details
#7--3details

Compiler report

input/code.cpp: In function 'bool isLegal(std::__cxx11::string)':
input/code.cpp:21:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     return m.size() == l || l == maxLength;
            ~~~~~~~~~^~~~
input/code.cpp: In function 'bool isLegalized(std::__cxx11::string)':
input/code.cpp:31:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     return m.size() == l;
            ~~~~~~~~~^~~~
input/code.cpp: In function 'int allPartitions(std::__cxx11::string)':
input/code.cpp:59:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i< allPart.size(); i++ )
                   ~^~~~~~~~~~~~~~~~
input/code.cpp:63:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < allPart[i].size(); j++)
                         ~~^~~~~~~~~~~~~~~~~~~

Code

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <bits/stdc++.h>
#define lint long long int

using namespace std;

int maxLength = 0;

bool isLegal(string s)
{
	int l = s.length();
	unordered_map<char, int> m;
    for (int i = 0; i < l; i++) {
        m[s[i]]++;
    }
    return m.size() == l || l == maxLength;
}

bool isLegalized(string s)
{
	int l = s.length();
	unordered_map<char, int> m;
    for (int i = 0; i < l; i++) {
        m[s[i]]++;
    }
    return m.size() == l;
}

void calcPart(vector<vector<string> >&allPart, vector<string> &currPart, int start, int n, string str)
{
    if (start >= n)
    {
        allPart.push_back(currPart);
        return;
    }
    for (int i = start; i < n; i++)
    {
        if (isLegal(str))
        {
            currPart.push_back(str.substr(start, i - start + 1));
            calcPart(allPart, currPart, i + 1, n, str);
            currPart.pop_back();
        }
    }
}

int allPartitions(string s)
{
    int n = s.length();
    vector<vector<string> > allPart;
    vector<string> currPart;
    calcPart(allPart, currPart, 0, n, s);
    int count = 0;
    for (int i=0; i< allPart.size(); i++ )
    {
    	string completePart = "";
    	bool permitted = true;
        for (int j = 0; j < allPart[i].size(); j++)
        {
        	if(isLegalized(allPart[i][j])) {
        		completePart += allPart[i][j] + " ";
        		continue;
			}
			permitted = false;
			break;
		} 
		if(permitted) {
			count++;
		}
    }
    return count;
}
 
int main()
{
    string s;
    cin >> s;
    maxLength = s.length();
    cout << allPartitions(s) << endl;
    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: 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
(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)