QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#451448#8521. Pattern Search IIHKOI0#WA 0ms3532kbC++201.1kb2024-06-23 13:31:192024-06-23 13:31:21

Judging History

你现在查看的是最新测评结果

  • [2024-06-23 13:31:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-06-23 13:31:19]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

void solve() {
    int c0 = 1, c1 = 1;
    string s; cin >> s;
    int ord = s.size();
    int ans = 0;
    while (s.size() >= 3) {
        string t;
        if (s.front() != 'a') t.push_back('a');
        for (int i = 0; i < s.size(); i++) {
            if (i > 0 && s[i] == 'b' && s[i - 1] == 'b') {
                t.push_back('a');
                ans += c0;
            }
            t.push_back(s[i]);
        }

        string ns;
        for (int i = 0; i < t.size(); i++) {
            if (i + 1 < t.size() && t[i + 1] == 'b') {
                ns.push_back('a'); i++;
            } else {
                ns.push_back('b');
            }
        }
        s = ns;
        int c2 = c0 + c1;
        c0 = c1; c1 = c2;
    }
    cout << ord + ans << '\n';
}

signed main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int T = 1;
    // cin >> T;
    while (T--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3524kb

input:

aabbaab

output:

8

result:

ok 1 number(s): "8"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

a

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

b

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

aa

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3500kb

input:

bb

output:

2

result:

wrong answer 1st numbers differ - expected: '3', found: '2'