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

Code

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    string _;
    getline(cin, _);

    for(int q = 0; q < t; q++) {
        string merkit;
        getline(cin, merkit);

        int len = merkit.length();
        int endi = len - 1;
        int maara = 0;
        for(int i = 0; i < len; i++) {
            if(merkit[i] == 'B') {
                while(merkit[endi] == 'B') {
                    if(endi == i) {
                        goto next;
                    }
                    endi--;
                }
                maara++;
                endi--;
            }
            if(endi == i) {
                goto next;
            }
        }
next:
        cout << maara << endl;
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
BBAABBBBAAABABBBAABBAABAAAABBB...

correct output
10
10
20
3
20
...

user output
10
10
20
3
20
...