题解:CF2065B Skibidus and Ohio
Wide_Master · · 题解
正言
容易发现,如果这个字符串中有一个相邻且相同的字符,那么答案为
否则答案为
代码
#include<bits/stdc++.h>
using namespace std;
string s;
int n,T,r;
int main()
{
cin>>T;
while(T--){
cin>>s;
s=" "+s;
r=-1;
n=s.length();
for(int i=n;i>=2;i--){
if(s[i]==s[i-1]){
r=i;
break;
}
}
if(r!=-1)cout<<1<<endl;
else cout<<n-1<<endl;
}
return 0;
}