本地运行样例是对的,但提交全是WA,求大佬调教

P1320 压缩技术(续集版)

bright_star_qwq @ 2024-10-26 00:50:45

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s0 = "0",s1;
    cin>>s1;
    int sz = sizeof(s1)-1;
    s0+=s1;
    for(int i = 0;i<sz-1;i++)
    {
        cin>>s1;
        s0+=s1;
    }
    int count_0 = 0,count_1 = 0;
    int flag = 0;
    cout<<sz<<" ";
    for(int i = 1;i<=sz*sz;i++)
    {
        flag = s0[i]-'0';
        if(s0[i] == '1')
            count_1++;
        else if(s0[i] == '0')
            count_0++;
        if(s0[i]!=s0[i-1])
        {
            if(flag)
            {
                cout<<count_0;
                count_0 = 0;
            }
            else
            {
                cout<<count_1;
                count_1 = 0;
            }
        }
        if(i == sz*sz)
        {
            if(flag)
                cout<<count_1;
            else
                cout<<count_0;
        }
    }
    return 0;
}

|