CodeForces 1144 A - Diverse Strings
程序员文章站
2022-05-08 21:13:22
...
题目: 传送门
思路: 先遍历一遍判断是否有重复,再讲其按大小排序检验其是否连续即可.
int vis[28];
std::vector<int> v;
int main() {
string s;
int t;
cin>>t;
while(t--) {
cin>>s;
int flag = 1;
memset(vis,0,sizeof(vis));
v.clear();
for(int i=0;i<s.size();i++) {
vis[s[i]-'a']++;
if(vis[s[i]-'a']>=2) flag =0;
v.push_back(s[i]-'a');
}
sort(v.begin(), v.end());
if(flag==0) cout<<"No"<<endl;
else {
int flag = 1;
for(int i=1;i<v.size();i++) {
if(v[i]!=v[i-1]+1) flag = 0;
}
if(flag == 0) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
}
return 0;
}~
推荐阅读
-
CodeForces 1320D - Reachable Strings
-
codeforces 1301A Three Strings 水
-
codeforces 559B Equivalent Strings (最小表示法)
-
【Codeforces】 Vitaly and Strings
-
CodeForces 1144 A - Diverse Strings
-
Codeforces - Reachable Strings
-
CodeForces 1320D - Reachable Strings
-
CodeForces - 559B Equivalent Strings 分治,递归
-
codeforces 559B Equivalent Strings 分治归并
-
codeforces 559B Equivalent Strings