Task: | Järjestys |
Sender: | motsgar |
Submission time: | 2022-01-22 13:06:32 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
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";}}