| Task: | Ositus |
| Sender: | Kertor |
| Submission time: | 2021-10-11 19:38:14 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 40 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 40 |
| #2 | TIME LIMIT EXCEEDED | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #5 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #6 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #7 | TIME LIMIT EXCEEDED | -- | 3 | details |
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: TIME LIMIT EXCEEDED
| input |
|---|
| mfyzvoxmppoxcvktmcjkryyocfweub... |
| correct output |
|---|
| 643221148 |
| user output |
|---|
| (empty) |
Test 6
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| weinscqmmpgbrlboocvtbptgbahmwv... |
| correct output |
|---|
| 831644159 |
| user output |
|---|
| (empty) |
Test 7
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| sxaoxcyrjoeieyinaqxwukgzdnhhsw... |
| correct output |
|---|
| 816016015 |
| user output |
|---|
| (empty) |
