QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#477551 | #8521. Pattern Search II | ucup-team1766# | WA | 0ms | 3804kb | C++23 | 479b | 2024-07-14 05:40:22 | 2024-07-14 05:40:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
string t; cin >> t; reverse(t.begin(), t.end());
int ans = 0;
if (t.back() == 'a') t.pop_back(), ans++;
if (t.back() == 'a') t.pop_back(), ans++;
while (t.size()) {
if (t.back() == 'b') t.pop_back();
ans++;
if (t.empty()) break;
if (t.back() == 'a') t.pop_back();
ans++;
if (t.empty()) break;
if (t.back() == 'a') t.pop_back(), ans++;
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
aabbaab
output:
8
result:
ok 1 number(s): "8"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
a
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
b
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
aa
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
bb
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
ab
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
ba
output:
2
result:
ok 1 number(s): "2"
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3644kb
input:
bbba
output:
6
result:
wrong answer 1st numbers differ - expected: '7', found: '6'