CSES - Datatähti 2022 loppu - Results
Submission details
Task:Järjestys
Sender:Totska
Submission time:2022-01-22 13:11:49 +0200
Language:C++17
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:23:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (ll j = 0; j < s.size(); j++)
                        ~~^~~~~~~~~~
input/code.cpp:12:11: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
     ll t, ans;
           ^~~

Code

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

#define fr(x) for(ll i = 0; i < x; i++)

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

    ll t, ans;
    string s;

    cin >> t;
    
    fr(t)
    {
        ans = 0;
        cin >> s;

        ll A = 0;
        for (ll j = 0; j < s.size(); j++)
        {
            if (s[j] == 'A')
            {
                ++A;
            }
            
        }

        ll B = 0;
        for (ll k = 0; k < A; k++)
        {
            if (s[k] == 'B')
            {
                ++B;
            }
        }
        
        cout << B << endl;
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
BBAABBBBAAABABBBAABBAABAAAABBB...

correct output
10
10
20
3
20
...

user output
10
10
20
3
20
...