过不了样例,80分,蒟蒻跪求解,另外想知道输出第二个0是怎么来的(有的时候)?

P1320 压缩技术(续集版)

Clean_Breeze @ 2020-02-03 14:54:16

#include <iostream>
#include <cmath>
using namespace std;
int main(){
    char n[40005]={0};
    int ans[40005]={0},i=1,v=1;
    while (cin >> n[i]){
        /*cout << "n: " << n << "    "
             << "i: " << i << "    "
             << "v: " << v << "    "
             << "ans[v]:  " << ans[v] << "    "
             << endl;*/
        if(n[i] != n[i-1]) v++;
        ans[v]++;
        i++;
    }
    cout << sqrt(i-1)<< " ";
    for(int j = 1;j <= v;j++)cout << ans[j] << " ";
    return 0;
} 

by liqingyang @ 2020-02-03 14:59:55

什么题?


by Clean_Breeze @ 2020-02-03 15:00:40

@liqingyang P1320


|