您的位置:首页 > 其它

Codeforces Round #454 (Div. 2, based on Technocup 2018 Elimination Round 4) C - Shockers

2017-12-24 01:58 411 查看
如果在!中没有出现过,那么这些字母没有嫌疑,如果在?或.中出现过,那么这些字母没有嫌疑。当最后只剩一个字母有嫌疑时,就确定了假设的字母,这时候我们只需要判别之后出现的?和!的数目即可。

#include <iostream>
#include <string>
using namespace std;
bool notis[30]={false},mayis[30]={false};
string str;
int main(){
int n,flag=0,cnt=0,tem,i,j;char p;
std::ios::sync_with_stdio(false);
cin>>n;
for(i=0;i<n;i++){
cin>>p>>str;
if(flag&&(p=='!'||p=='?'))cnt++;
else{
tem=str.length();
if(p=='!'){
for(j=0;j<tem;j++)mayis[str[j]-'a']=true;
for(j=0;j<26;j++){
if(!mayis[j])notis[j]=true;
mayis[j]=false;
}
}else for(j=0;j<tem;j++)notis[str[j]-'a']=true;
for(tem=j=0;j<26;j++)if(!notis[j])tem++;
if(tem==1)flag=1;
}
}
printf("%d",cnt>0?(cnt-1):0);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐