双指针思路,为什么只有20分?

P1320 压缩技术(续集版)

btxrrvt @ 2024-02-13 17:13:48

双指针思路,为什么只能20分?

#include <bits/stdc++.h>
using namespace std;

int main() {
    freopen("data.txt", "r", stdin);
    string s;
    string as = "";
    int d = s.size();
    while (cin >> s) {
        as += s;
    }
    cout << pow(as.size(), 0.5) << " ";
    int idx1 = 0, idx2 = 0;
    while (idx1 < as.size()) {
        if (as[idx2] != as[idx1]) {
            cout << idx2 - idx1 << " ";
            idx1 = idx2;
        }
        idx2 ++;
    }

    return 0;
}

|