STUDYING ALPHABET

Description:

Not everyone probably knows that Chef has younder brother Jeff. Currently Jeff learns to read. He knows some subset of the letter of Latin alphabet. In order to help Jeff to study, Chef gave him a book with the text consisting of N words. Jeff can read a word iff it consists only of the letters he knows. Now Chef is curious about which words his brother will be able to read, and which are not. Please help him! INPUT The first line of the input contains a lowercase Latin letter string S, consisting of the letters Jeff can read. Every letter will appear in S no more than once. The second line of the input contains an integer N denoting the number of words in the book. Each of the following N lines contains a single lowecase Latin letter string Wi, denoting the ith word in the book. OUTPUT For each of the words, output "Yes" (without quotes) in case Jeff can read it, and "No"(without quotes) otherwise. CONSTRAINTS 1 |S| 26 1 N 1000 1 |Wi| 12 Each letter will appear in S no more than once. S, Wi consist only of lowercase Latin letters. SUBTASKS Subtask #1 (31 point): |S| = 1, i.e. Jeff knows only one letter. Subtask #2 (69 point) : no additional constraints Test Case 1 Input (stdin) act 2 cat dog Expected Output Yes No Test Case 2 Input (stdin) god 2 act cat Expected Output No No

Program :

#include <bits/stdc++.h>

using namespace std;


int main() {

    string s;

    cin>>s;

    std::vector<char> m;

    for(int i = 0;i<s.size();i++)

    {

        m.push_back(s[i]);

    }

   int t;

   cin>>t;

   string s1;

   while(t--)

   {

       

       cin>>s1;

       int f=0;

       for(int i = 0;i<s1.size();i++)

       {

           if(find(m.begin(),m.end(),s1[i]) == m.end())

           {

               f=1;

               break;

           }

       }

       

       if(f)

       {

           std::cout << "No" << std::endl;

       }

       else{

           std::cout << "Yes" << std::endl;

       }

       

   }

}