CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:ABC-poisto
Sender:Lieska
Submission time:2020-10-16 19:03:14 +0300
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED42
#2ACCEPTED58
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void testi(){
string s;
cin >> s;
int n=s.size();
int a=0, b=0, c=0;
for (int i=0; i<n; ++i){
if (s[i]=='A') a++;
if (s[i]=='B') b++;
if (s[i]=='C') c++;
}
if (a>(b+c)) {
cout << 2*(b+c) << "\n";
return;
}
if (b>(a+c)) {
cout << 2*(a+c) << "\n";
return;
}
if (c>(a+b)) {
cout << 2*(a+b) << "\n";
return;
}
if (n%2==1){
cout << n-1 << "\n";
return;
}
cout << n << "\n";
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//�l� k�yt�, jos teht�v� on interaktiivinen!
int t;
cin >> t;
while (t--) testi();
}

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
...
Truncated

Test 2

Group: 2

Verdict: ACCEPTED

input
100
CCAAACBCBBCCACBBBCCACCCBABBCAB...

correct output
48
4
4
96
70
...

user output
48
4
4
96
70
...
Truncated