Daffodil International University
Problem Link
//Please follow from main function
#include<bits/stdc++.h>
using namespace std;
int main()
{
int tc, p=1, r=2, o=1, a=1, m=2, i=1, n=1, c, d;
cin>>tc;
string s1;
while(tc--)
{
string s1;
map<char, int>mp;
map<char, int>::iterator it;
cin>>s1;
int l=0, d=0;
p=1, r=2, o=1, a=1, m=2, i=1, n=1;
for(int i=0; i<s1.size(); i++){
mp[s1[i]]++;
}
for(it=mp.begin(); it!=mp.end(); it++){
if(it->first=='p' && it->second >=1) l++;
else if(it->first=='r' && it->second >=2) l++;
else if(it->first=='o' && it->second >=1) l++;
else if(it->first=='a' && it->second >=1) l++;
else if(it->first=='m' && it->second >=2) l++;
else if(it->first=='i' && it->second >=1) l++;
else if(it->first=='n' && it->second >=1) l++;
else if(it->first=='g' && it->second >=2) l++;
//cout<<it->first<<' '<<it->second<<endl;
}
for(it=mp.begin(); it!=mp.end(); it++){
if(it->first=='c' && it->second >=1) d++;
else if(it->first=='o' && it->second >=1) d++;
else if(it->first=='d' && it->second >=1) d++;
else if(it->first=='i' && it->second >=1) d++;
else if(it->first=='n' && it->second >=1) d++;
else if(it->first=='g' && it->second >=1) d++;
//cout<<it->first<<' '<<it->second<<endl;
}
if(l==8 || d==6) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
mp.clear();
}
return 0;
}
0 Comments