P1320压缩技术(续集版)过不了,有谁来救救本蒟蒻吗

P1320 压缩技术(续集版)

Zjx2003 @ 2022-11-13 15:00:11


#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
long long ctr[40000];
int main() {
    char word1 = '0';
    int word = 0;
    int pre = 2, count = 0, i = 0, c = 200, y = 0;
    memset(ctr, 0, sizeof(ctr));
    while (count < c * c) {
        word1 = cin.get();
        if (word1 == '\n' && y == 0) {
            c = count;
            y = 1;
            continue;
        }
        if (word1 == '\n')
            continue;
        word = word1 - '0';
        if (pre == word) {
            ++ctr[i];
        }
        if (pre == (1 ^ word)) {
            ++i;
        }
        pre = word;
        ++count;
    }
    cout << sqrt(count) << " ";
    for (int o = 0; o <= i; ++o) {
        cout << ctr[o] + 1 << " ";
    }
}

|