问题 F: Not Found
时间限制: 1.000 Sec 内存限制: 128 MB
提交 状态
题目描述
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print None instead.
Constraints
1≤|S|≤105 (|S| is the length of string S.)
S consists of lowercase English letters.
沙拉查词翻译:
给定一个由小写英文字母组成的字符串S。查找S中不出现的最小的小写英文字母。如果每个小写英文字母都出现在S中,打印None。
约束
1≤|S|≤105 (|S|为字符串S的长度)
“S”由小写英文字母组成。
输入
Input is given from Standard Input in the following format:
S
输出
Print the lexicographically smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print None instead.
样例输入 Copy
atcoderregularcontest
样例输出 Copy
b
提示
The string atcoderregularcontest contains a, but does not contain b.
# include<bits/stdc++.h>
using namespace std;
char c;
int flag;
set<char>ee;
int main(){
while((c=getchar())!='\n'){
ee.insert(c);//在set中输入
}
char s='a';//从第一个'a'开始
for(int t=1;t<=26;t++)//在26个字母中找
{
flag=0;//用于判断 ,每次更新
set<char>::iterator it;//迭代器 ,set集合会自动将内部元素排好的,而且还会去重挺好用
for(it=ee.begin();it!=ee.end();it++){
if(*it==s){
flag=1;//flag等于1就意思是找到了
break;
}
}
if(flag==0) //没找到就直接给它输出然后结束了
{
cout<<(char)s;return 0;
}
s++;//更新下一个字母呗
}
cout<<"None";//都有了就输出none
}