求助!!!为什么会20分啊?

P1320 压缩技术(续集版)

Eric12 @ 2023-08-02 14:28:07

#include <iostream>
#include <string>
using namespace std;
string s;
int zero,one;
bool couted;
int main()
{
    while(cin>>s)
    {
        if(!couted)
        {
            cout<<s.size()<<' ';
            couted=true;
        }
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='0')
            {
                if(one!=0)
                {
                    cout<<one<<' ';
                    one=0;
                }
                zero++;
            }
            if(s[i]=='1')
            {
                if(zero!=0)
                {
                    cout<<zero<<' ';
                    zero=0;
                }
                one++;
            }
        }
    }
    if(one!=0)cout<<one<<endl;
    if(zero!=0)cout<<zero<<endl;
    return 0;
}

by IOI_AK_TLR @ 2023-08-02 15:00:01

@Eric12 是不是这个原因?


by Eric12 @ 2023-08-02 18:41:29

@IOI_AK_TLR 知道了,谢谢


|