CSES - Datatähti 2022 loppu - Results
Submission details
Task:Järjestys
Sender:Juho
Submission time:2022-01-22 13:09:21 +0200
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:14:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<s.size();j++){
                     ~^~~~~~~~~

Code

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


int n, a, b;
string s;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        a=0;
        b=0;
        for(int j=0;j<s.size();j++){
            if(s[j]=='A'){
                a++;
            }
        }
        for(int j=0;j<a;j++){
            if(s[j]=='B'){
                b++;
            }
        }
        cout<<b<<"\n";
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
BBAABBBBAAABABBBAABBAABAAAABBB...

correct output
10
10
20
3
20
...

user output
10
10
20
3
20
...