专栏文章
题解:CF2065B Skibidus and Ohio
CF2065B题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @miqak0al
- 此快照首次捕获于
- 2025/12/04 01:39 3 个月前
- 此快照最后确认于
- 2025/12/04 01:39 3 个月前
正言
容易发现,如果这个字符串中有一个相邻且相同的字符,那么答案为 ,因为它可以变为自己左边或者右边的字符。
否则答案为 。
代码
CPP#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;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...