#6∼#10 都 TLE 了。
#include <iostream>
#include <cstring>
using namespace std;
char a[1000001],b[1000001],c='2';
int x=0;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> a;
for(int i=0; i<strlen(a);i++)
{
if(a[i]!=c)
{
b[x]=a[i];
c=a[i];
x++;
}
}
if(b[strlen(b)-1]=='0')cout << strlen(b);
else cout << strlen(b)-1;
return 0;
}
样例没问题,#1∼#5 也都 AC 了。