CSES - Datatähti 2022 loppu - Results
Submission details
Task:Järjestys
Sender:hltk
Submission time:2022-01-22 13:03:48 +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;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    string s;
    cin >> s;
    int n = (int) s.size();
    int c[n + 1][2] {};
    for (int i = 0; i < n; ++i) {
      c[i + 1][0] = c[i][0] + (s[i] == 'A');
      c[i + 1][1] = c[i][1] + (s[i] == 'B');
    }
    cout << c[c[n][0]][1] << endl;
  }
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
BBAABBBBAAABABBBAABBAABAAAABBB...

correct output
10
10
20
3
20
...

user output
10
10
20
3
20
...
Truncated