Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. string a = "qwertyuiopasdfghjklzxcvbnm";
  9.  
  10. int main()
  11. {
  12.     int n, counter = 0;
  13.     cin >> n;
  14.    
  15.     for(int i = 0; i < n; i++)
  16.     {
  17.         char c;
  18.         string s;
  19.         cin >> c >> s;
  20.        
  21.         if(c == '!')
  22.         {
  23.             string st = "", st2 = "";
  24.             for(int j = 0; j < s.size(); j++)
  25.             {
  26.                 if(st.find(s[j]) == string::npos)
  27.                     st.push_back(s[j]);
  28.             }
  29.        
  30.             for(int j = 0; j < a.size(); j++)
  31.             {
  32.                 if(st.find(a[j]) != string::npos)
  33.                     st2.push_back(a[j]);
  34.             }
  35.            
  36.             a = st2;
  37.            
  38.         }
  39.        
  40.         if(c == '.')
  41.         {
  42.             for(int j = 0; j < s.size(); j++)
  43.                 a.erase(a.find(s[j]) + a.begin());
  44.         }
  45.        
  46.         cout << a.size() << ' ';
  47.        
  48.         if(a.size() == 1 && c == '?')
  49.             counter++;
  50.     }
  51.    
  52.     cout << counter;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement