QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#445361 | #8521. Pattern Search II | ucup-team3695# | WA | 0ms | 3736kb | C++20 | 754b | 2024-06-16 01:34:10 | 2024-06-16 01:34:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a = 0, b = 1;
string s;
cin >> s;
long long ans = (int)size(s);
deque<char> S(begin(s), end(s)), T;
for (;;)
{
tie(a, b) = pair{b, a + b};
if (S.size() == 1)
break;
if (S.front() == 'b')
S.push_front('a');
if (S.back() == 'a')
S.pop_back();
if (S.size() == 1)
break;
T.clear();
for (int i = 0; i < (int)size(S);)
{
if (S[i] == 'a')
{
if (i < (int)size(S) - 1 && S[i + 1] == 'b')
{
T.push_back('a');
i += 2;
}
else
{
T.push_back('b');
i++;
}
}
else
{
T.push_back('a');
i++;
ans += b;
}
}
S.swap(T);
}
cout << ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
aabbaab
output:
8
result:
ok 1 number(s): "8"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
a
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
b
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
aa
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
bb
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
ab
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
ba
output:
2
result:
ok 1 number(s): "2"
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3524kb
input:
bbba
output:
9
result:
wrong answer 1st numbers differ - expected: '7', found: '9'