P1320求助,本地能过测试测试了极限数据也能过但是全WA

P1320 压缩技术(续集版)

anaoai @ 2021-12-06 19:13:02

#include <bits/stdc++.h>
using namespace std;
int main(){
    string longx;
    int cache=1;
    int chang=0;
    getline(cin,longx);
    chang=longx.length();
    int solve[50000];
    memset(solve,0,sizeof(solve));
    for(int i=0;i<chang;i++){
        solve[i]=longx[i]-'0';
    }
    for(int i=1;i<chang;i++){
        string ss;
        getline(cin,ss);
        for(int j=0;j<=chang;j++){
            solve[i*chang+j]=ss[j]-'0';
        }
    }
    /*for(int i=0;i<chang*chang;i++){
        cout<<solve[i];
    }*/
    cout<<chang<<" ";
    for(int i=1;i<=chang*chang;i++){
        if(solve[i]==solve[i-1]){
            cache++;
        }else{
            cout<<cache<<" ";
            cache=1;
        }
}
    return 0;
}
/*
0001000
0001000
0001111
0001000
0001000
0001000
1111111

7 3 1 6 1 6 4 3 1 6 1 6 1 3 7

00
00

2 4
*/

by anaoai @ 2021-12-06 19:30:18

已解决

chang=longx.length()-1;//编译器差异

if(solve[0]!=0){
            cout<<"0 ";
}//第一个数表示连续有几个0

|