CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:Matenstein
Submission time:2021-10-05 19:32:35 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#30.01 s1, 2, 3details
#40.01 s1, 2, 3details
#50.01 s2, 3details
#60.02 s3details
#7--3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:19:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int a = 0; a < input.size(); a++)
                  ~~^~~~~~~~~~~~~~
input/code.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int b = 0; b < seen.size() - 1; b++)if (input[a] == seen[b]) 
                   ~~^~~~~~~~~~~~~~~~~
input/code.cpp:45:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (a == input.size() - 1 && current != a) 
       ~~^~~~~~~~~~~~~~~~~~~
input/code.cpp:52:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int a = 0; a < parts.size(); a++)
                  ~~^~~~~~~~~~~~~~

Code

#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct partition
{
	int start, end;
};

long long maxi = 1;
int main()
{
	string input;
	cin >> input;

	int current = 0;
	vector<char>seen; vector<partition>parts;
	for (int a = 0; a < input.size(); a++)
	{
		seen.push_back(input[a]);
		for (int b = 0; b < seen.size() - 1; b++)if (input[a] == seen[b]) 
		{
			if (b == current)
			{
				partition p;
				p.start = current, p.end = a;
				parts.push_back(p);
				current = a;
				seen[current] = '1';
			}
			else
			{
				partition p;
				p.start = current, p.end = b;
				parts.push_back(p);
				p.start = b, p.end = a;
				parts.push_back(p);
				seen[current] = '1';
				seen[b] = '1';
				current = a;
			}
			break;
		}
		if (a == input.size() - 1 && current != a) 
		{
			partition p;
			p.start = current, p.end = a;
			parts.push_back(p);
		}
	}
	for (int a = 0; a < parts.size(); a++)
	{
		int n = parts[a].end - parts[a].start;
		if (input[parts[a].start] == input[parts[a].end]) { if (n > 1) { for (int b = 0; b < n; b++)maxi *= 2; maxi--; } }
		else for (int b = 0; b < n; b++) { maxi *= 2; }
	}
	long long modulo = 10;
	for (long long i = 0; i < 9; i++)
	{
		modulo *= 10;
	}
	modulo += 7;
	cout << maxi % modulo;
}

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:

input
abcabaacbc

correct output
120

user output
225147

Test 4

Group: 1, 2, 3

Verdict:

input
aaxxxxxxaa

correct output
4

user output
6911

Test 5

Group: 2, 3

Verdict:

input
mfyzvoxmppoxcvktmcjkryyocfweub...

correct output
643221148

user output
-5149979225

Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
-9852416767

Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
(empty)