CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:ABC-poisto
Sender:jubidubi
Submission time:2020-10-17 17:10:28 +0300
Language:C++11
Status:READY
Result:42
Feedback
groupverdictscore
#1ACCEPTED42
#20
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2--2details

Code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int solve(string s) {
	int mx = 0;
	int n = s.length();
	for (int i = 0; i < n-1; ++i) {
		if (s[i] != s[i+1]) {
			string temp = "";
			for (int j = 0; j < n; ++j) {
				if (j != i && j != i+1) temp += s[j];
			}
			mx = max(mx, solve(temp) + 2);
		}
	}
	return mx ;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;

		cout << solve(s) << endl;
	}
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
100
CABC
BABCCBCA
CBBCBBAC
ACAA
...

correct output
4
8
8
2
2
...

user output
4
8
8
2
2
...

Test 2

Group: 2

Verdict:

input
100
CCAAACBCBBCCACBBBCCACCCBABBCAB...

correct output
48
4
4
96
70
...

user output
(empty)