☰
一个字符串中的 “01“ 和 “10“ 子串个数是否相同
2026/10/10 4:05:07 网站建设 项目流程

一个字符串中的 "01" 和 "10" 子串个数是否相同只取决于这个字符串开头和结尾的字符是否相同。

#include<bits/stdc++.h> #define int long long using namespace std; void solve() { int n;cin>>n; string s;cin>>s;s='#'+s; int l,r;cin>>l>>r; if(s[1]==s[r]) cout<<"Yes"<<endl; else { if(l==1||r==n) cout<<"Yes"<<endl; else cout<<"No"<<endl; } } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T=1;cin>>T; while(T--) { solve(); } return 0; }

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询