版权声明:随意转载哦......但还是请注明出处吧: https://blog.csdn.net/dreaming__ldx/article/details/82793790
传送门
考虑每次摆石头都会消去最外层的一个连续颜色串。
所以只用统计一下有多少段颜色即可。
代码:
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int n,cnt=0;
int main(){
scanf("%s",s+1),n=strlen(s+1);
for(int i=2;i<=n;++i)if(s[i]!=s[i-1])++cnt;
cout<<cnt;
return 0;
}