CSES - Datatähti 2022 loppu - Results
Submission details
Task:Järjestys
Sender:motsgar
Submission time:2022-01-22 13:06:32 +0200
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>t;
for(int i=0;i<t;i++){
string s;
cin>>s;
int a=0,b=s.size()-1;
int c=0;
while(a!=b){
while(s[a]=='A')a++;
while(s[b]=='B')b--;
if(a>=b)break;
s[a]='A';
s[b]='B';
c++;
}
cout<<c<<"\n";
}
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
BBAABBBBAAABABBBAABBAABAAAABBB...

correct output
10
10
20
3
20
...

user output
10
10
20
3
20
...
Truncated