Task: | Järjestys |
Sender: | hltk |
Submission time: | 2022-01-22 13:03:48 +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; 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; } }