CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:andreibe
Submission time:2021-10-05 13:40:21 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1--1, 2, 3details
#20.01 s1, 2, 3details
#30.01 s1, 2, 3details
#40.01 s1, 2, 3details
#50.99 s2, 3details
#6--3details
#7--3details

Compiler report

input/code.cpp: In function 'int total(std::vector<std::__cxx11::basic_string<char> >, int)':
input/code.cpp:24:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (s.find(c) != -1) {
       ~~~~~~~~~~^~~~~
input/code.cpp:32:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (size_t i = 0; i < size; i++)
                     ~~^~~~~~

Code

#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <set>
#include <unordered_map>

#include <chrono>
using namespace std::chrono;
using namespace std;
typedef unsigned long long ll;
//https://cses.fi/dt/
string str;
int total(vector<string> v, int index) {
	char c = str[index];
	int size = v.size();
	for (size_t i = 0; i < v.size(); i++)
	{
		string s = v[i];
		if (s.find(c) != -1) {
			v.erase(v.begin() + i);
			i--;
		}
		else {
			v[i] = c + s;
		}
	}
	for (size_t i = 0; i < size; i++)
	{
		v.push_back(string(1, c));
	}
	if (index != 0) {
		return total(v, index - 1);
	}
	else {
		return v.size();
	}
}
int main()
{
	cin >> str;
	auto start = high_resolution_clock::now();
	int len = str.length();
	if (len == 1) {
		cout << 1;
		//return 0;
	}
	char last = str[len - 1];
	vector<string> v = { string(1,last) };
	int tot = total(v, len - 2);
	cout << tot << "\n";
	auto stop = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop - start);
	cout << duration.count() << endl;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
a

correct output
1

user output
(empty)

Test 2

Group: 1, 2, 3

Verdict:

input
abcdefghij

correct output
512

user output
512
163

Test 3

Group: 1, 2, 3

Verdict:

input
abcabaacbc

correct output
120

user output
120
67

Test 4

Group: 1, 2, 3

Verdict:

input
aaxxxxxxaa

correct output
4

user output
4
30

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)